1*76404edcSAsim Jamshed#!/bin/bash 2*76404edcSAsim Jamshed 3*76404edcSAsim Jamshed## ABSOLUTE path to the spawn-fcgi binary 4*76404edcSAsim JamshedSPAWNFCGI="/home/weigon/projects/spawn-fcgi/src/spawn-fcgi" 5*76404edcSAsim Jamshed 6*76404edcSAsim Jamshed## ABSOLUTE path to the PHP binary 7*76404edcSAsim JamshedFCGIPROGRAM="/usr/local/bin/php" 8*76404edcSAsim Jamshed 9*76404edcSAsim Jamshed## TCP port to which to bind on localhost 10*76404edcSAsim JamshedFCGIPORT="1026" 11*76404edcSAsim Jamshed 12*76404edcSAsim Jamshed## number of PHP children to spawn 13*76404edcSAsim JamshedPHP_FCGI_CHILDREN=10 14*76404edcSAsim Jamshed 15*76404edcSAsim Jamshed## maximum number of requests a single PHP process can serve before it is restarted 16*76404edcSAsim JamshedPHP_FCGI_MAX_REQUESTS=1000 17*76404edcSAsim Jamshed 18*76404edcSAsim Jamshed## IP addresses from which PHP should access server connections 19*76404edcSAsim JamshedFCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.2.10" 20*76404edcSAsim Jamshed 21*76404edcSAsim Jamshed# allowed environment variables, separated by spaces 22*76404edcSAsim JamshedALLOWED_ENV="ORACLE_HOME PATH USER" 23*76404edcSAsim Jamshed 24*76404edcSAsim Jamshed## if this script is run as root, switch to the following user 25*76404edcSAsim JamshedUSERID=wwwrun 26*76404edcSAsim JamshedGROUPID=wwwrun 27*76404edcSAsim Jamshed 28*76404edcSAsim Jamshed 29*76404edcSAsim Jamshed################## no config below this line 30*76404edcSAsim Jamshed 31*76404edcSAsim Jamshedif test x$PHP_FCGI_CHILDREN = x; then 32*76404edcSAsim Jamshed PHP_FCGI_CHILDREN=5 33*76404edcSAsim Jamshedfi 34*76404edcSAsim Jamshed 35*76404edcSAsim Jamshedexport PHP_FCGI_MAX_REQUESTS 36*76404edcSAsim Jamshedexport FCGI_WEB_SERVER_ADDRS 37*76404edcSAsim Jamshed 38*76404edcSAsim JamshedALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS" 39*76404edcSAsim Jamshed 40*76404edcSAsim Jamshedif test x$UID = x0; then 41*76404edcSAsim Jamshed EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN" 42*76404edcSAsim Jamshedelse 43*76404edcSAsim Jamshed EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN" 44*76404edcSAsim Jamshedfi 45*76404edcSAsim Jamshed 46*76404edcSAsim Jamshed# copy the allowed environment variables 47*76404edcSAsim JamshedE= 48*76404edcSAsim Jamshed 49*76404edcSAsim Jamshedfor i in $ALLOWED_ENV; do 50*76404edcSAsim Jamshed E="$E $i=${!i}" 51*76404edcSAsim Jamsheddone 52*76404edcSAsim Jamshed 53*76404edcSAsim Jamshed# clean the environment and set up a new one 54*76404edcSAsim Jamshedenv - $E $EX 55