PHP init script to go with nginx?

Volodymyr Kostyrko c.kworr at gmail.com
Fri Jun 13 15:43:37 MSD 2008


Phillip B Oldham wrote:
> Thanks Volodymyr.
> 
> How would one add in PHP_FCGI_MAX_REQUESTS to such scripts?

Dunno, maybe like this:

>>
>> Here are some examples. They do create named sockets per user.
>>
>> Linux:
>>
>> #!/bin/ash
>> #
>> # chkconfig: 234 25 75
>> # description: php FastCGI daemon
>>
>> case $1 in
>> restart)
>>         /etc/init.d/phpFcgid stop
>>         /etc/init.d/phpFcgid start
>>         ;;
>> start)
>>         users="www"
>>         www_childs='2'
	www_maxrequests='1000'
>>         for user in ${users}; do
>>                 socketdir="/tmp/.fastcgi.${user}"
>>                 mkdir -p ${socketdir}
>>                 chown ${user}:nobody ${socketdir}
>>                 chmod 0750 ${socketdir}
>>                 eval export PHP_FCGI_CHILDREN=\${${user}_childs}
		eval export PHP_FCGI_MAX_REQUESTS=\${${user}_maxrequests}
>>                 su -m ${user} -c "/opt/php5/bin/php-cgi -b 
>> ${socketdir}/socket&"
>>         done
>>         ;;
>> stop) /usr/bin/pkill php-cgi ;;
>> esac
>>
>> FreeBSD:
>>
>> #!/bin/sh
>>
>> # PROVIDE: phpFcgid
>> # REQUIRE: LOGIN
>> # KEYWORD: shutdown
>>
>> . /etc/rc.subr
>>
>> name="phpFcgid"
>> rcvar=`set_rcvar`
>>
>> load_rc_config $name
>> : ${phpFcgid_enable="NO"}
>> : ${phpFcgid_users="www"}
>> : ${phpFcgid_children="2"}
: $phpFcgid_maxrequests="0"}
>>
>> start_cmd=phpFcgid_start
>> stop_cmd=phpFcgid_stop
>>
>> phpFcgid_start() {
>>         echo "Starting $name."
>>         export PHP_FCGI_CHILDREN=${phpFcgid_children}
	if [ "${phpFcgid_maxrequests}" -ne "0" ]; then
		export PHP_FCGI_MAX_REQUESTS="${phpFcgid_maxrequests}"
>>         for user in ${phpFcgid_users}; do
>>                 socketdir="/tmp/.fastcgi.${user}"
>>                 mkdir -p ${socketdir}
>>                 chown ${user}:www ${socketdir}
>>                 chmod 0750 ${socketdir}
>>                 su -m ${user} -c "/usr/local/bin/php-cgi -b 
>> ${socketdir}/socket&"
>>         done
>> }
>>
>> phpFcgid_stop() {
>>         echo "Stopping $name."
>>         pids=`pgrep php-cgi`
>>         pkill php-cgi
>>         wait_for_pids $pids
>> }
>>
>> run_rc_command "$1"
>>
> 

I personally don't see any point setting 'em.

-- 
Sphinx of black quartz judge my vow.






More information about the nginx mailing list