LINUX.ORG.RU
ФорумAdmin

Ошибка 502 Bad Gateway - NGINX + PHP-FPM 5.6

 , , ,


0

1

Добрый день уважаемые коллеги! Столкнулся с бедой и никак не могу исправить данную проблему - 502 Bad Gateway (nginx)! И уже сутки никак не могу найти ошибку! :(

  • Вот конфиг файла /etc/php/5.6/fpm/php-fpm.conf:
include=/etc/php/5.6/fpm/pool.d/*.conf
chroot = /var/www
chdir = /
pid = /var/run/php/php5.6-fpm.pid
error_log = /var/log/php5.6-fpm.log
  • Вот конфиг файла /etc/php/5.6/fpm/pool.d/www.conf:
user = www-data
group = www-data
listen = /var/run/php/php5.6-fpm.sock
listen.owner = www-data
listen.group = www-data
  • Вот конфиг файла /etc/nginx/nginx.conf:
user www-data;
worker_processes 2;
timer_resolution 100ms;
worker_rlimit_nofile 8192;
worker_priority -5;
error_log  /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
        worker_connections 1024;
        use epoll;
        multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        sendfile_max_chunk 128k;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 10;
        keepalive_requests 100;
        reset_timedout_connection on;
        client_body_timeout 5;
        client_header_timeout 5;
        send_timeout 3;
        client_header_buffer_size 2k;
        large_client_header_buffers 2 2k;
        client_body_buffer_size 256k;
        access_log off;
        types_hash_max_size 2048;
        server_tokens off;

        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/sites-enabled/*;
        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log crit;

        charset utf-8;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";
        gzip_min_length 1100;
        gzip_proxied any;
        gzip_comp_level 4;
        gzip_http_version 1.1;
        gzip_vary on;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        client_max_body_size 8M;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

                server {
                        listen 80;
                        server_name service1.place.ru;
                        server_name_in_redirect off;

                        access_log /var/log/nginx/service.access_log;
                        error_log /var/log/nginx/service.error_log;

                        root /var/www/service1.place.ru;

                        fastcgi_intercept_errors on;

                        index index.php;

                                location ~ \.php$ {
                                        try_files $uri =404;
                                        include /etc/nginx/fastcgi_params;
                                        fastcgi_index index.php;
                                        fastcgi_pass unix:/var/run/php5.6-fpm.sock;
                                        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                                }
                }
}
  • Все эти папки пустые:
/etc/nginx/sites-available
/etc/nginx/sites-enabled
/etc/nginx/conf.d


Последнее исправление: Aladmin (всего исправлений: 7)
listen = /var/run/php/php5.6-fpm.sock

vs

fastcgi_pass unix:/var/run/php5.6-fpm.sock

слушаете «сюда», а направляете «туда». Не?

anonymous
()
Ответ на: комментарий от Aladmin

HELP

No input file specified. - подскажите пожалуйста в какую сторону копать!? :(

Вот права на папку:

root@Polis:/# ls -lha /var/www/service1.place.ru
total 16K
drwxrwxrwx 2 www-data www-data 4.0K Nov 25 07:46 .
drwxrwxrwx 9 www-data www-data 4.0K Nov 25 05:45 ..
-rwxrwxrwx 1 root     root        4 Nov 25 05:57 index.html
-rwxrwxrwx 1 www-data www-data   23 Nov 25 07:46 index.php
Aladmin
() автор топика
Ответ на: комментарий от deep-purple
  • Да вот ничего особенного там не вижу:
root@Polis:/var/log# cat php5.6-fpm.log
[24-Nov-2019 06:25:01] NOTICE: error log file re-opened
[25-Nov-2019 05:31:28] NOTICE: Terminating ...
[25-Nov-2019 05:31:28] NOTICE: exiting, bye-bye!
[25-Nov-2019 05:31:29] NOTICE: fpm is running, pid 14566
[25-Nov-2019 05:31:29] NOTICE: ready to handle connections
[25-Nov-2019 05:31:29] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 05:37:39] NOTICE: Terminating ...
[25-Nov-2019 05:37:39] NOTICE: exiting, bye-bye!
[25-Nov-2019 05:37:39] NOTICE: fpm is running, pid 14629
[25-Nov-2019 05:37:39] NOTICE: ready to handle connections
[25-Nov-2019 05:37:39] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 05:46:26] NOTICE: Terminating ...
[25-Nov-2019 05:46:26] NOTICE: exiting, bye-bye!
[25-Nov-2019 05:46:26] NOTICE: fpm is running, pid 14780
[25-Nov-2019 05:46:26] NOTICE: ready to handle connections
[25-Nov-2019 05:46:26] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 06:02:17] NOTICE: Terminating ...
[25-Nov-2019 06:02:17] NOTICE: exiting, bye-bye!
[25-Nov-2019 06:02:17] NOTICE: fpm is running, pid 15078
[25-Nov-2019 06:02:17] NOTICE: ready to handle connections
[25-Nov-2019 06:02:17] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 06:08:22] NOTICE: Terminating ...
[25-Nov-2019 06:08:22] NOTICE: exiting, bye-bye!
[25-Nov-2019 06:08:23] NOTICE: fpm is running, pid 15139
[25-Nov-2019 06:08:23] NOTICE: ready to handle connections
[25-Nov-2019 06:08:23] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 06:11:12] NOTICE: Terminating ...
[25-Nov-2019 06:11:12] NOTICE: exiting, bye-bye!
[25-Nov-2019 06:11:12] NOTICE: fpm is running, pid 15252
[25-Nov-2019 06:11:12] NOTICE: ready to handle connections
[25-Nov-2019 06:11:12] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 06:20:22] NOTICE: Reloading in progress ...
[25-Nov-2019 06:20:22] NOTICE: reloading: execvp("/usr/sbin/php-fpm5.6", {"/usr/sbin/php-fpm5.6", "--nodaemonize", "--fpm-config", "/etc/php/5.6/fpm/php-fpm.conf"})
[25-Nov-2019 06:20:22] NOTICE: using inherited socket fd=7, "/var/run/php/php5.6-fpm.sock"
[25-Nov-2019 06:20:22] NOTICE: using inherited socket fd=7, "/var/run/php/php5.6-fpm.sock"
[25-Nov-2019 06:20:22] NOTICE: fpm is running, pid 15252
[25-Nov-2019 06:20:22] NOTICE: ready to handle connections
[25-Nov-2019 06:20:22] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 06:33:11] NOTICE: Terminating ...
[25-Nov-2019 06:33:11] NOTICE: exiting, bye-bye!
[25-Nov-2019 06:33:12] NOTICE: fpm is running, pid 15496
[25-Nov-2019 06:33:12] NOTICE: ready to handle connections
[25-Nov-2019 06:33:12] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 07:33:20] NOTICE: Reloading in progress ...
[25-Nov-2019 07:33:20] NOTICE: reloading: execvp("/usr/sbin/php-fpm5.6", {"/usr/sbin/php-fpm5.6", "--nodaemonize", "--fpm-config", "/etc/php/5.6/fpm/php-fpm.conf"})
[25-Nov-2019 07:33:20] NOTICE: using inherited socket fd=7, "/var/run/php/php5.6-fpm.sock"
[25-Nov-2019 07:33:20] NOTICE: using inherited socket fd=7, "/var/run/php/php5.6-fpm.sock"
[25-Nov-2019 07:33:20] NOTICE: fpm is running, pid 15496
[25-Nov-2019 07:33:20] NOTICE: ready to handle connections
[25-Nov-2019 07:33:20] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 07:41:33] NOTICE: Terminating ...
[25-Nov-2019 07:41:33] NOTICE: exiting, bye-bye!
[25-Nov-2019 07:41:33] NOTICE: fpm is running, pid 15994
[25-Nov-2019 07:41:33] NOTICE: ready to handle connections
[25-Nov-2019 07:41:33] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 07:46:38] NOTICE: Terminating ...
[25-Nov-2019 07:46:38] NOTICE: exiting, bye-bye!
[25-Nov-2019 07:46:38] NOTICE: fpm is running, pid 16104
[25-Nov-2019 07:46:38] NOTICE: ready to handle connections
[25-Nov-2019 07:46:38] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 08:09:12] NOTICE: Terminating ...
[25-Nov-2019 08:09:12] NOTICE: exiting, bye-bye!
[25-Nov-2019 08:09:12] NOTICE: fpm is running, pid 16214
[25-Nov-2019 08:09:12] NOTICE: ready to handle connections
[25-Nov-2019 08:09:12] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 08:46:35] NOTICE: Terminating ...
[25-Nov-2019 08:46:35] NOTICE: exiting, bye-bye!
[25-Nov-2019 08:46:35] NOTICE: fpm is running, pid 16353
[25-Nov-2019 08:46:35] NOTICE: ready to handle connections
[25-Nov-2019 08:46:35] NOTICE: systemd monitor interval set to 10000ms
[25-Nov-2019 08:47:58] NOTICE: Terminating ...
[25-Nov-2019 08:47:58] NOTICE: exiting, bye-bye!
[25-Nov-2019 08:47:58] NOTICE: fpm is running, pid 16389
[25-Nov-2019 08:47:58] NOTICE: ready to handle connections
[25-Nov-2019 08:47:58] NOTICE: systemd monitor interval set to 10000ms

Aladmin
() автор топика
Ответ на: комментарий от Aladmin

Вангую что в настройках fastcgi в nginx что-то не задано или задано что-то не то. Если файл /etc/nginx/snippets/fastcgi-php.conf есть попробуй заменить phpшный location на такой

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
    }
MrClon ★★★★★
()
Ответ на: комментарий от MrClon

Да такой файл есть, но вот что внутри:

root@Polis:/etc/nginx/snippets# vi fastcgi-php.conf
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
# fastcgi_split_path_info ^(.+\.php)(/.+)$;

# Check that the PHP script exists before passing it
# try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
# set $path_info $fastcgi_path_info;
# fastcgi_param PATH_INFO $path_info;

# fastcgi_index index.php;
# include fastcgi.conf;
Aladmin
() автор топика
Ответ на: комментарий от Aladmin

Вот что пишет в логе, как с этим можно побороться?

root@Polis:/var/log/nginx# tail service.error_log
2019/11/26 02:15:04 [error] 19425#19425: *1 FastCGI sent in stderr: "Unable to open primary script: /var/www/service1.place.ru/index.php (No such file or directory)" while reading response header from upstream, client: 81.211.37.66, server: service1.place.ru, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php5.6-fpm.sock:", host: "service1.place.ru"
2019/11/26 02:15:05 [error] 19425#19425: *1 FastCGI sent in stderr: "Unable to open primary script: /var/www/service1.place.ru/index.php (No such file or directory)" while reading response header from upstream, client: 81.211.37.66, server: service1.place.ru, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php5.6-fpm.sock:", host: "service1.place.ru"
2019/11/26 02:15:51 [error] 19425#19425: *10 FastCGI sent in stderr: "Unable to open primary script: /var/www/service1.place.ru/index.php (No such file or directory)" while reading response header from upstream, client: 81.211.37.66, server: service1.place.ru, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php5.6-fpm.sock:", host: "service1.place.ru"
Aladmin
() автор топика
Ответ на: комментарий от Aladmin

Ты его редактировал? По дефолту там директивы не закоментированы, должно быть

# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;

или

# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;
MrClon ★★★★★
()
Ответ на: комментарий от MrClon

Сделал вот так и не пашет:

                server {
                        listen 80;
                        server_name service1.place.ru;
                        server_name_in_redirect off;

                        access_log /var/log/nginx/service.access_log;
                        error_log /var/log/nginx/service.error_log;

                        root /var/www/service1.place.ru;

                        fastcgi_intercept_errors on;

                        index index.php index.html index.htm;

                        location / {
                                try_files $uri $uri/ /index.php?q=$request_uri;
                        }



 location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
    }



#                               location ~ \.php$ {
#                                       fastcgi_split_path_info ^(.+\.php)(/.+)$;
#                                       try_files $uri =404;
#                                       include /etc/nginx/fastcgi_params;
#                                       fastcgi_index index.php;
#                                       fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
#                                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#                               }
                }
Aladmin
() автор топика
Ответ на: комментарий от Aladmin

На всякий случай замечу, что PHP 5.6 уже давно надо заменить на что-то типа 7.2 хотя бы. Ну, вдруг вы не следите.

Borifed
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.