Suddenly, i would get a 502 Bad Gateway page while trying to access my localhost nginx web server.
Looking at nginx log, found these
$ cat /var/log/nginx/error.log
---
2014/06/26 00:26:10 [crit] 1260#0: *2 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost"
I remembered having firing the system updater few hours ago. Looking at the logs
cat /var/log/apt/history.log
I see php5-fpm, php5-mysql, php5-common, php5-readline, php5-cli have been updated. I guess this is what caused the breakup.
I tried re-installing them
$ sudo apt-get install --reinstall php5-fpm
---
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
libwebkitgtk-3.0-0 : Depends: libjavascriptcoregtk-3.0-0 (= 2.4.2-1ubuntu0.1) but 2.4.3-1ubuntu2 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
I ran
$ apt-get -f install
Apparently the last update didn’t complete. But i’m still getting the 502 error :-/
But then googling more about the nginx log, someone posted a magical solution here
$ chmod 666 /var/run/php5-fpm.sock
Problem Solved 😀