This is an init script to run spawn-fcgi and php on Ubuntu. Its adapted from Aaron Schaefer's excellent post on how to run wordpress on nginx - the configuration this site runs on.
To install it follow the instructions below
Download the source.
fastcgi-php
#!/bin/sh
## BEGIN INIT INFO
# Provides: FastCGI servers for PHP
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Start FastCGI servers with PHP.
# Description: Start PHP with spawn-fcgi. For use with nginx and lighttpd.
#
#
### END INIT INFO
#
# Author: Derrick Petzold
#
# http://derrickpetzold.com/index.php/2010/07/02/init-script-fastcgi-php-ubuntu/
#
RUN_USER=nobody
RUN_GROUP=nogroup
LISTEN_ADDRESS=127.0.0.1
LISTEN_PORT=53217
SPAWN_FCGI=/opt/lighttpd/bin/spawn-fcgi
PHP_CGI=/opt/php5/bin/php-cgi
PID_FILE=/var/run/fastcgi-php.pid
d_start() {
if [ -f $PID_FILE ]; then
echo -n " already running"
else
start-stop-daemon --start -p $PID_FILE \
--exec /usr/bin/env -- $SPAWN_FCGI -f $PHP_CGI \
-u $RUN_USER -g $RUN_GROUP -a $LISTEN_ADDRESS -p $LISTEN_PORT \
-P $PID_FILE
fi
}
d_stop() {
start-stop-daemon --stop --quiet --pidfile $PID_FILE \
|| echo -n " not running"
if [ -f $PID_FILE ]; then
rm $PID_FILE
fi
}
case "$1" in
start)
echo -n "Starting FastCGI: $0 "
d_start
echo "."
;;
stop)
echo -n "Stopping FastCGI: $0 "
d_stop
echo "."
;;
restart)
echo -n "Restarting FastCGI: $0 "
d_stop
sleep 1
d_start
;;
*)
echo "usage: $0 {start|stop|restart}"
;;
esac
git clone git://gist.github.com/510245.git fastcgi-php.gist vim fastcgi-php.gist/fastcgi-php # Update with your pathnames chmod 755 fastcgi-php.gist/fastcgi-php mv fastcgi-php.gist/fastcgi-php /etc/init.d/ update-rc.d fastcgi-php defaults /etc/init.d/fastcgi-php start rm -rf fastcgi-php.gist



