FreeBSD : nginx with php-cgi on unix socket
UPDATE : Check out recent committed /usr/ports/www/spawn-fcgi/, it comes with a better spawn-fcgi rc.d script. Please use the script from the post. However, the spawn-fcgi.sh provided does not have option to run via unix socket. I have submitted the patch.
Few days ago, I posted a write-up, FreeBSD : php-cgi spawn-fcgi rc.d script for nginx, on running php-cgi on port 8888. But how do I run it via unix socket? It is trivial with spawn-fcgi rc.d script. Just add the flags to /etc/rc.conf
spawnfcgi_flags="-s /tmp/php-fastcgi.socket -u www -g www -f /usr/local/bin/php-cgi"
Next, replace the line
fastcgi_pass 127.0.0.1:8888;
with this
fastcgi_pass unix:/tmp/php-fastcgi.socket;
Lastly restart both php-cgi and nginx:
/usr/local/etc/rc.d/spawnfcgi restart && /usr/local/etc/rc.d/nginx restart
That’s all. You have your php-cgi on unix socket.
Friday, April 17th, 2009



