Skip to content

Instantly share code, notes, and snippets.

@slok
Created June 23, 2011 06:52
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 slok/1042051 to your computer and use it in GitHub Desktop.
Save slok/1042051 to your computer and use it in GitHub Desktop.
Daemon script to start the spawn-cgi service with php-cgi, for example to support php with fcgi in Nginx
#!/bin/bash
#/etc/rc.d/rc.php-cgi
#spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -g nobody -f /usr/bin/php-cgi
IP=127.0.0.1
PORT=9000
USER=nobody
GROUP=nobody
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000
PHP_CGI=/usr/bin/php-cgi
SPAWN_FCGI=/usr/bin/spawn-fcgi
SPAWN_FCGI_ARGS="-a $IP -p $PORT -u $USER -g $GROUP -f $PHP_CGI"
RETVAL=0
start() {
echo "[START] Spawn-fcgi with php-cgi"
$SPAWN_FCGI $SPAWN_FCGI_ARGS
}
stop() {
echo "[STOP] Spawn-fcgi with php-cgi"
killall -w -u $USER $PHP_CGI
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: rc.php-cgi {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