Why the 502 error when installing php5-fpm + nginx?

Learn to configure the server manually on VPS. Installed nginx + php5-fpm. I do not understand why it is necessary to specify 127.0.0.1, not the address of my server. Although put the address, nothing came of it.

But unable to configure it correctly. Here is the server nginx running, but 502 error - 176.112.212.179/index.php

server {
 listen 80 default_server;
 listen [::]:80 default_server ipv6only=on;

 root /var/www/htdocs;
 index index.php;

 location / {
 try_files $uri $uri/ =404;
}

location ~ \.php$ {
 # fastcgi_split_path_info ^(.+\.php)(.*)$;
 location 127.0.0.1:9000;
 fastcgi_index index.php;

 fastcgi_param DOCUMENT_ROOT /htdocs;
 fastcgi_param SCRIPT_FILENAME /htdocs$fastcgi_script_name;
 fastcgi_param PATH_TRANSLATED /htdocs$fastcgi_script_name;

 include fastcgi_params;
 fastcgi_param QUERY_STRING $query_string;
 fastcgi_param REQUEST_METHOD $request_method;
 fastcgi_param CONTENT_TYPE $content_type;
 fastcgi_param CONTENT_LENGTH $content_length;
 fastcgi_intercept_errors on;
 fastcgi_ignore_client_abort off;
 fastcgi_connect_timeout 60;
 fastcgi_send_timeout 180;
 fastcgi_read_timeout 180;
 set by the fastcgi_buffer_size 128k;
 fastcgi_buffers directives 4 256k;
 fastcgi_busy_buffers_size 256k;
 fastcgi_temp_file_write_size 256k;
}

 location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico)$ {
 access_log off;
 expires max;
}

 location ~ /\.ht {
 deny all;
}

}


What's the problem?
July 8th 19 at 11:16
1 answer
July 8th 19 at 11:18
Solution
php-fpm usually listens to the address 127.0.0.1 and port 9000, it's what you point out as the backend.
This is done so you can't access your server as server.EN:9000 and to get directly to php-fpm.
In all neponyatkah - see the logs - /var/log/ logs of nginx and php-fpm
That is, even if I have VPS , I still have to specify 127.0.0.1 ? - Mohamed.Funk commented on July 8th 19 at 11:21
If you have VDS installed nginx and php-fpm, then the answer is Yes.
If nginx is installed on the same vds, and php-fpm on the other - no. - Daphne_Roob commented on July 8th 19 at 11:24
Just in case I will explain - 127.0.0.1 - this is not "some Internet address" is "localhost", that is "the same computer". - Daphne_Roob commented on July 8th 19 at 11:27
: all I knew) I solved the problem by installing php listen = 127.0.0.1:9000; Thank you) - Mohamed.Funk commented on July 8th 19 at 11:30

Find more questions by tags PHPNginx