Skip to content

Instantly share code, notes, and snippets.

@erotte
Created December 3, 2011 23:39
Show Gist options
  • Save erotte/1428513 to your computer and use it in GitHub Desktop.
Save erotte/1428513 to your computer and use it in GitHub Desktop.
Setting up Wordpress with nginX and php-cgi
#!/bin/bash
BIND=127.0.0.1:9000
# BIND=/tmp/php.socket
USER=www-data
PHP_FCGI_CHILDREN=3
PHP_FCGI_MAX_REQUESTS=1000
PHP_CGI=/usr/bin/php5-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
start() {
echo -n "Starting PHP FastCGI: "
start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
RETVAL=$?
echo "$PHP_CGI_NAME."
}
stop() {
echo -n "Stopping PHP FastCGI: "
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
echo "$PHP_CGI_NAME."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: php5-fcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
# Dennis' Version:
# PHP_SCRIPT=/usr/bin/php5-fcgi
# RETVAL=0
# case "$1" in
# start)
# echo "Starting fastcgi"
# $PHP_SCRIPT
# RETVAL=$?
# ;;
# stop)
# echo "Stopping fastcgi"
# killall -9 php-cgi
# RETVAL=$?
# ;;
# restart)
# echo "Restarting fastcgi"
# killall -9 php-cgi
# $PHP_SCRIPT
# RETVAL=$?
# ;;
# *)
# echo "Usage: php-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