1 #!/bin/sh 2 # 3 # php-cgi - php-fastcgi swaping via spawn-fcgi 4 # 5 # chkconfig: - 85 15 6 # description: Run php-cgi as app server 7 # processname: php-cgi 8 # config: /etc/sysconfig/phpfastcgi (defaults RH style) 9 # pidfile: /var/run/php_cgi.pid10 # Note: See how to use this script :11 # http://www.cyberciti.biz/faq/rhel-fedora-install-configure-nginx-php5/12 # Source function library.13 . /etc/rc.d/init.d/functions14 15 # Source networking configuration.16 . /etc/sysconfig/network17 18 # Check that networking is up.19 [ "$NETWORKING" = "no" ] && exit 020 21 spawnfcgi="/usr/local/bin/spawn-fcgi"22 php_cgi="/usr/local/php/bin/php-cgi"23 prog=$(basename $php_cgi)24 server_ip=127.0.0.125 server_port=900026 server_user=www27 server_group=www28 server_childs=25629 pidfile="/var/run/php_cgi.pid"30 31 # do not edit, put changes in /etc/sysconfig/phpfastcgi32 [ -f /etc/sysconfig/phpfastcgi ] && . /etc/sysconfig/phpfastcgi33 34 start() {35 [ -x $php_cgi ] || exit 136 [ -x $spawnfcgi ] || exit 237 echo -n $"Starting $prog: "38 daemon $spawnfcgi -a ${server_ip} -p ${server_port} -u ${server_user} -g ${server_group} -P ${pidfile} -C ${server_childs} -f ${php_cgi}39 retval=$?40 echo41 return $retval42 }43 44 stop() {45 echo -n $"Stopping $prog: "46 killproc -p ${pidfile} $prog -QUIT47 retval=$?48 echo49 [ -f ${pidfile} ] && /bin/rm -f ${pidfile}50 return $retval51 }52 53 restart(){54 stop55 sleep 256 start57 }58 59 rh_status(){60 status -p ${pidfile} $prog61 }62 63 case "$1" in64 start)65 start;;66 stop)67 stop;;68 restart)69 restart;;70 status)71 rh_status;;72 *)73 echo $"Usage: $0 {start|stop|restart|status}"74 exit 375 esac