Nginx, PHP5-FPM and Permission Denied Errors

After upgrading to Nginx 1.4.7 and PHP 5.4.28 (or 5.5.12), you may start seeing errors like the following:

2014/05/03 13:27:41 [crit] 4202#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client:, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xx.xx.xx.xx"

The fix is to edit /etc/php5/fpm/pool.d/www.conf and set the listen.mode to 666 (be sure to uncomment the line as well):

listen.mode = 0666

Load Balancing a Reverse Proxy with Nginx, PHP5-FPM & SSL

Continuing with our migration to Nginx (see previous posts here and here), the next set of servers to move were a load balanced group of PHP servers. Each server consists of an http server on port 80, an https server on port 443 and an upstream PHP server on port 8000.

  • 1 to n upstream PHP servers can be configured, either local or remote
  • configuration supports both http (80) and https (443)
  • SSL is terminated before being passed to the upstream server
  • PHP upstream server uses PHP5-FPM via a local socket
  • static files are served directly via Nginx and are set to max expires

There are also some future optimizations I’m currently looking at: