MENU

腾讯云镜像环境502处理思路

January 3, 2020 • Read: 416 • 环境配置

网站报错502,先在配置文件里配上日志

access_log  /var/log/666.log;
error_log  /var/log/666.error.log;

查看错误日志

2020/01/03 10:14:52 [crit] 14674#0: *28 connect() to unix:/run/php-fpm/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 123.160.132.123, server: 123.54.142.123, request: "GET /1.php HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php7.0-fpm.sock:", host: "123.54.142.123"

新的环境出现502,网上所谓的由于 php 参数设置导致的可能性非常小,根据经验可以排除

停止和启动php(新手命令)

service php-fpm stop
service php-fpm start

nginx 配置路径

/etc/nginx/conf.d

查到配置文件是以9000 端口监听php的

fastcgi_pass   127.0.0.1:9000

查询是否监听9000 端口(配置文件)

netstat -ant | grep 9000

查询php是否启动

ps aux|grep php

找到php的配置文件/etc/php-fpm.conf 发现最后一行etc/php-fpm.d/*.conf,进去找到php对应版本的配置文件
etc/php-fpm.d/www.conf,在文件中查找 listen

listen = /dev/shm/php-fpm-default.sock

此时我们需要根据配置文件的listen地址做对应的修改:

    location ~ .+\.php($|/) {
            set $script $uri;
            set $path_info "";
            if ($uri ~ "^(.+\.php)(/.+)") {
                    set $script $1;
                    set $path_info $2;
            }
            fastcgi_pass     unix:/dev/shm/php-fpm-default.sock;(这里的路径就是上面我们找到的)
            #fastcgi_pass   127.0.0.1:9000;(注释掉原始配置)
            fastcgi_index    index.php?IF_REWRITE=1;
            fastcgi_param    PATH_INFO    $path_info;
            fastcgi_param    SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            fastcgi_param    SCRIPT_NAME    $script;
            include        fastcgi_params;

处理完记得重启

nginx -s reload

兼总条贯 知至知终

最后编辑于: January 8, 2020