HowTo: Fix “unix:/var/run/php5-fpm.sock failed (13: Permission denied)”
If you look at the /usr/local/nginx/logs/error.log and see the following error, you can use the next steps to resolve the problem.
connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: xx.xxx.xx.xx
Change the owner of php5-fpm.sock and set permission to 660.
chown nginx:nginx /var/run/php5-fpm.sock
chmod 660 /var/run/php5-fpm.sock
Open the php5-fpm configuration file to edit the settings below:
Use the same user/group that the web server is running under. i.e. The nginx service is running under the user nginx while lighttpd is running under the user www-data.
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
Restart the PHP FPM service
sudo service php5-fpm restart