Nginx 502 Bad Gateway cost me more time than the actual Ubuntu + PHP-FPM + MySQL installation I was working on. In my case the 502 Bad Gateway error on my installation was the result of a parameter mismatch between /etc/ningx/sites-available/default and /etc/php5/fpm/pool.d/www.conf. In order to solve the 502 Bad Gateway problem edit the Nginx file /etc/ningx/sites-available/default.
1 | nano /etc/ningx/sites-available/default |
And look for the commented line # fastcgi_pass unix:/var/run/php5-fpm.sock; and uncomment the line.
1 | fastcgi\_pass unix:/var/run/php5-fpm.sock; |
You location ~ .php$ { section should look similar to mine.
1 | location ~ .php$ { |
The final two steps are to restart Nginx and PHP-FPM.
1 | sudo service nginx restart |
1 | sudo service php5-fpm restart |
Now you have a working installation like it should have been from the beginning.
debian, nginx, php, ubuntu — Sep 23, 2013