Script to spawn php5-cgi to enable Nginx to serve PHP code/pages

Volodymyr Kostyrko c.kworr at gmail.com
Thu Nov 6 14:00:29 MSK 2008


Mark Alan wrote:
>> 1. Works like a charm for me for 1 year.
> 
> That seems interesting. I am inclined to give it a try.
> 
> How do you set them up? Are you using Ubuntu or a Debian based Linux?
> Could you post example scripts on how to set up the Unix domain sockets?

I use FreeBSD at large, but have composed a tiny snippet for some old 
CentOS server:

#!/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="user1 user2"
         user1_childs='8'
         user2_childs='2'
         user3_childs='8'
         for user in ${users}; do
                 socketdir="/tmp/.php.fastcgi.${user}"
                 mkdir -p ${socketdir}
                 chown ${user}:nobody ${socketdir}
                 chmod 0750 ${socketdir}
                 eval export PHP_FCGI_CHILDREN=\${${user}_childs}
                 su -m ${user} -c "/opt/php5/bin/php-cgi -b 
${socketdir}/socket&"
         done
         ;;
stop) /usr/bin/pkill php-cgi ;;
esac

This way only the user running php and group www gets access to the socket.

>> 3. TCP _is_ slower then unix sockets. And it _is_ buffered too.
> Do you have any pointers to papers or other work about comparative speed 
> testing?

http://oss.sgi.com/archives/netdev/2003-03/msg00024.html

That was long ago... But the numbers show UDP is 25% slower then AF_UNIX 
at establishing connections and TCP can handle only 22% of AF_UNIX 
throughoutput. And I don't think AF_INET will ever become faster then 
AF_UNIX - it covers a lot more possibilities and as such require more 
computational power.

-- 
Sphinx of black quartz judge my vow.






More information about the nginx mailing list