Skip to content

Instantly share code, notes, and snippets.

@rchampourlier
Created July 12, 2011 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rchampourlier/1079094 to your computer and use it in GitHub Desktop.
Save rchampourlier/1079094 to your computer and use it in GitHub Desktop.
SystemV service startup script for php-fcgi for reverse proxied php on nginx
#!/bin/sh
#
# php-fcgi Start and stop FastCGI processes
#
# chkconfig: - 80 20
# description: Spawn FastCGI scripts to be used by web servers
### BEGIN INIT INFO
# Provides: php-fcgi
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: PHP5 FastCgi Spawned processes
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
COMMAND=/usr/bin/spawn-fcgi
ADDRESS=127.0.0.1
PORT=9000
USER=www
GROUP=www
PHPCGI=/usr/bin/php-cgi
PIDFILE=/var/run/fastcgi-php.pid
RETVAL=0
PHP_FCGI_MAX_REQUESTS=500
PHP_FCGI_CHILDREN=2
start() {
echo -n $"Starting $PHPCGI: "
export PHP_FCGI_MAX_REQUESTS PHP_FCGI_CHILDREN
$COMMAND -a $ADDRESS -p $PORT -u $USER -g $GROUP -f $PHPCGI -P $PIDFILE
retval=$?
echo
return $retval
}
stop() {
echo -n $"Stopping $PHPCGI: "
/usr/bin/killall -9 php-cgi
retval=$?
echo
return $retval
}
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart|reload)
stop
start
RETVAL=$?
;;
*)
echo "Usage: fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment