Обсуждение статьи тематического каталога: Настройка Nginx для поддержки PHP при помощи FastCGI (php http nginx web fastcgi)Ссылка на текст статьи: http://www.opennet.me/base/net/nginx_php.txt.html
#!/bin/bash# source function library
. /etc/init.d/functions## bring up local interface ########################
ifconfig lo 127.0.0.1 up## php options #####################################
PHPFCGI="/usr/bin/php"
PHP_OPTIONS="-b 127.0.0.1:9000"## number of PHP children to spawn
PHP_FCGI_CHILDREN=1## number of request before php-process will be restarted
PHP_FCGI_MAX_REQUESTS=1000FCGI_WEB_SERVER_ADDRS="127.0.0.1"
EA="PATH USER PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
## copy the allowed environment variables
E=
for i in $EA; do
E="$E $i=${!i}"
doneEX="$PHPFCGI $PHP_OPTIONS"
## php options stop ################################
NGINX_OPTIONS=""
RETVAL=0
prog="webif"start() {
echo -n $"Starting $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
nohup env - $E sh -c "$EX" &> /dev/null &daemon /usr/sbin/nginx $NGINX_OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/webif
fi;
echo
return $RETVAL
}stop() {
echo -n $"Stopping $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
killproc /usr/sbin/nginx
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/webif
killall -9 php
fi;
echo
return $RETVAL
}reload(){
echo -n $"Reloading $prog: "
killproc /usr/sbin/nginx -HUP
RETVAL=$?
echo
return $RETVAL
}restart(){
stop
start
}case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
*)
echo $"Usage: $0 {start|stop|restart|reload}"
RETVAL=1
esacexit $RETVAL