fastcgi init script on centos加强版

#!/bin/bash
#
# fcgi     Startup script for fcgi
#
# processname: fcgi

# Source function library
. /etc/rc.d/init.d/functions

## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/app/lighttpd/bin/spawn-fcgi"

## ABSOLUTE path to the PHP binary
FCGIPROGRAM="/opt/app/php-cgi/bin/php-cgi"

## TCP port to which to bind on localhost
#FCGIPORT="1026"
FCGI_SOCKET="/tmp/php-fastcgi.sock"

FCGI_PIDFILE="/var/run/spawn-fcgi.pid"

## number of PHP children to spawn
PHP_FCGI_CHILDREN=20

## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=500

## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1"

# allowed environment variables, separated by spaces
ALLOWED_ENV="SHELL PATH USER"

## if this script is run as root, switch to the following user
USERID=rsync
GROUPID=daemon


################## no config below this line

if test x$PHP_FCGI_CHILDREN = x; then
  PHP_FCGI_CHILDREN=5
fi

export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS


ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if test x$UID = x0; then
  #EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN"
  EX="$SPAWNFCGI -s $FCGI_SOCKET -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN -P $FCGI_PIDFILE"
else
  #EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN"
  EX="$SPAWNFCGI -s $FCGI_SOCKET -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN -P $FCGI_PIDFILE"
fi

# copy the allowed environment variables
E=

for i in $ALLOWED_ENV; do
  E="$E $i=${!i}"
done

# clean the environment and set up a new one
#env - $E $EX




prog="fcgi" 



RETVAL=0

start() {
        echo -n $"Starting $prog: " 
        daemon env - $E $EX
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: " 
        rm -f $FCGI_PIDFILE $FCGI_SOCKET
        killproc $FCGIPROGRAM
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        condrestart)
                if [ -f /var/lock/subsys/$prog ]; then
                        stop
                        start
                fi
                ;;
        status)
                status $FCGIPROGRAM
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|condrestart|status}" 
                RETVAL=1
esac

exit $RETVAL

 放在/etc/init.d/下面,方便

你可能感兴趣的:(PHP,socket,centos,F#,lighttpd)