--- /dev/null
+#!/bin/sh
+#
+# Created 2010-09-26 by presbrey@mit.edu
+#
+# php This shell script takes care of starting and stopping PHP
+#
+# chkconfig: - 80 30
+# description: manages PHP spawned in FastCGI mode with spawn-fcgi
+# processname: php-cgi
+# config: /etc/php.ini
+
+
+# Source function library
+if [ -f /etc/rc.d/init.d/functions ]; then
+. /etc/rc.d/init.d/functions
+elif [ -f /etc/init.d/functions ]; then
+. /etc/init.d/functions
+elif [ -f /etc/rc.d/functions ]; then
+. /etc/rc.d/functions
+fi
+
+pidfile=${PIDFILE-/var/run/php.pid}
+lockfile=${LOCKFILE-/var/lock/subsys/php}
+PHP_BIN=/usr/bin/php-cgi
+PHP_SOCK=/tmp/php.sock
+PHP_USER=lighttpd
+PHP_GROUP=apache
+PHP_CHILDREN=8
+
+# Read configuration (environment etc.)
+if [ -f /etc/sysconfig/php ]; then
+ . /etc/sysconfig/php
+fi
+
+RETVAL=0
+
+# See how we were called.
+case "$1" in
+ start)
+ # Start daemons.
+ echo -n "Starting php: "
+ daemon --pidfile=${pidfile} spawn-fcgi -C $PHP_CHILDREN -f $PHP_BIN -u $PHP_USER -g $PHP_GROUP -s $PHP_SOCK -P $pidfile
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && touch ${lockfile}
+ ;;
+ stop)
+ # Stop daemons.
+ echo -n "Stopping php: "
+ killproc -p ${pidfile} -d 1 $PID_BIN -9
+ RETVAL=$?
+ echo
+ [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ status)
+ status -p $pidfile $PHP_BIN
+ RETVAL=$?
+ ;;
+ *)
+ echo "Usage: php {start|stop|restart|reload|status}"
+ RETVAL=2
+esac
+
+exit $RETVAL