LNMP安装后子域名访问工程报错502 Bad Gateway

LNMP安装好nginx、mysql、php后,放好代码,搭建完数据库,使用

IP/工程名

可以正常访问,但是给这个工程配置了子域名,用子域名访问就直接报错

502 Bad Gateway

解决这个问题,进入到PHP安装目录,比如/usr/local/php/conf,编辑文件php-fpm.conf,将

[www]
listen = /tmp/php-cgi.sock

修改为:

[www]
listen = 127.0.0.1:9000

其中,这个修改的端口9000,可以从nginx的配置中获取,查看nginx的目录,比如/usr/local/nginx/conf/vhost,找到配置这个工程子域名的文件,查看

location ~ [^/].php(/|$)
    {
        # comment try_files $uri =404; to enable pathinfo
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
        #include pathinfo.conf;
    }

OK。保存重启即可。

原文地址:https://www.cnblogs.com/xianxh/p/9373650.html