Browse files

Add php-cgi init script.

  • Loading branch information...
1 parent a4fb1c5 commit a55e7f43194c59591a2baa046dd242e52eb68304 @huacnlee committed Sep 25, 2011
Showing with 47 additions and 0 deletions.
  1. +1 −0 README.textile
  2. +3 −0 install
  3. +43 −0 php-cgi
View
1 README.textile
@@ -9,3 +9,4 @@ h2. Include services and Application/Config files location
* Redis (/usr/local/bin/redis, /usr/local/etc/redis.conf)
* MongoDB (/usr/local/bin/mongod, /usr/local/etc/mongodb.conf)
* Nginx (/usr/local/bin/nginx, nginx.conf in /usr/local/nginx/conf)
+* PHP-CGI (sudo apt-get install php5-cgi)
View
3 install
@@ -10,6 +10,9 @@ sudo update-rc.d mongodb defaults
sudo cp nginx /etc/init.d/
sudo mkdir /var/run/nginx
sudo update-rc.d nginx defaults
+
+sudo cp php-cgi /etc/init.d/
+sudo update-rc.d php-cgi defaults
echo "-------------------------------------------------------------------"
echo "DONE"
ls /etc/init.d
View
43 php-cgi
@@ -0,0 +1,43 @@
+#!/bin/bash
+# To install php5-cgi
+# sudo apt-get install php5-cgi
+BIND=127.0.0.1:9000
+USER=www-data
+PHP_FCGI_CHILDREN=15
+PHP_FCGI_MAX_REQUESTS=1000
+
+PHP_CGI=/usr/bin/php-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: php-fastcgi {start|stop|restart}"
+ exit 1
+ ;;
+esac
+exit $RETVAL

0 comments on commit a55e7f4

Please sign in to comment.