After tiresomely testing the config – I eventually got it to work.
Once you know how it’s really easy but I kept getting a “502 Bad Gateway” error that confused me.
Benefits of sockets over TCP:
- Faster connection over sockets than TCP; 20% boost
- More secure as sockets are harder to break their permissions
Anyway, here’s what you need to do. All config locations are the defaults installed by Debian Squeeze.
Add Dotdeb’s sources in your Debian /etc/apt/source.list
## PHP5-FPM deb http://packages.dotdeb.org stable all deb-src http://packages.dotdeb.org stable all
Then install php5-fpm:
apt-get update apt-get install php5-fpm
Change the settings in /etc/php5/fpm/php-fpm.conf
pid = /var/run/php5-fpm.pid error_log = /var/log/php5-fpm.log daemonize = yes include=/etc/php5/fpm/pool.d/*.conf
Recommended settings in /etc/php5/fpm/pool.d/www.conf
;listen = 127.0.0.1:9000 listen = /var/run/php5-fpm.sock listen.owner = www-data listen.group = www-data listen.mode = 0666 user = www-data group = www-data php_flag[display_errors] = off php_admin_value[error_log] = /var/log/fpm-php.www.log php_admin_flag[log_errors] = on php_admin_value[error_reporting] = 0 php_admin_value[memory_limit] = 128M php_admin_value[date.timezone] = Europe/London
Start/Restart Nginx and PHP5-FPM and voila
/etc/init.d/nginx restart /etc/init.d/php5-fpm start
Everything should be running smoothly. Enjoy your new faster server!
Thanks to the people below who wrote about it first.
- http://www.kutukupret.com/2010/10/26/how-to-make-php-fpm-listen-on-both-tcp-and-unix-socket/
- http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian
- http://norbyit.se/blog/2011/01/configuring-php-fpm/
- http://andreas-lehr.com/blog/archives/491-nginx-wordpress-php-fpm-on-debian-squeeze.html
- http://www.webhostingtalk.com/showthread.php?t=1025286
- http://www.kutukupret.com/2010/10/26/how-to-make-php-fpm-listen-on-both-tcp-and-unix-socket/
For those budding PHP developers out there, you want to run your eyes over this!
CL Auth is finally in round 2 of BETA testing. BETA v0.2 offers better optimisation, new functions, better documentation and easier customisation. It also quashes some known bugs from the previous BETA.