From 7d4d1b667d303c041a9a78841adf51589337083f Mon Sep 17 00:00:00 2001 From: Joe Presbrey Date: Sun, 26 Sep 2010 17:01:31 +0000 Subject: [PATCH] php: init.d script git-svn-id: svn://sql.mit.edu/sql@186 a142d4bd-2cfb-0310-9673-cb33a7e74f58 --- etc/init.d/php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 etc/init.d/php diff --git a/etc/init.d/php b/etc/init.d/php new file mode 100755 index 0000000..d8fc292 --- /dev/null +++ b/etc/init.d/php @@ -0,0 +1,68 @@ +#!/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 -- 2.45.1