buzzoole code

How to solve the 502 bad gateway issue with NGINX and PHP5

502 Bad Gateway issue on NGINX serverSo you installed locally or in your remote web server Nginx following this guide for the first configuration and then you added a new domain with the virtual host file. But then when you try accessing on your domain NGINX is not happy and tells you “502 Bad Gateway”.
Let’s see how to solve this problem.

Is PHP running properly?

First of all we need to make sure the problem is not in the site configuration in the virtual host file. To do so we can create a plain index.html file in the webroot.
If we can see this file correctly from the browser we can do with the next step, otherwise I suggest to check how to set up a virtual host file.

With the command:

we can check if there is any php process running.
The response of the command in the terminal should look like:

If the result doesn’t contains any “php-fpm” process maybe something has gone wrong in the first installation process, so we have to reinstall the packages for php5. (You can skip if in your terminal the results are like the above).

Set up PHP-FPM to communicate correctly with NGINX

The php-fpm process has to listen the correct thing to run properly and to execute the code passed by NGINX. To edit the configuration of php-fpm we need to change a line on the file: /etc/php5/fpm/pool.d/www.conf.

and then look for

(around line 34 on my computer)
and change it to:

Just one step to go, restart php-fpm:

and everything now is good to go.

Questo Blog è Indipendente e Supportato Solamente dai suoi Lettori.
Se vuoi sostenerlo, Condivi il Post sui Social Network:
Aggiungi il nostro sito alla Whitelist di Adblock Plus
e magari Fai Anche un Acquisto su Amazon partendo da Qui
(a te non costa nulla!).