18910140161

Linux nginx 配置后不能访问php

顺晟科技

2022-09-15 18:04:03

263

望大佬们支持一下呢,哪里出现了问题,在线等
谢谢!

nginx 配置文件:

server
    {
        listen 80;
        #listen [::]:80 default_server ipv6only=on;
        server_name www.web.com;
        location / {
            index front.php index.html index.php;
            root /home/wwwroot/default/web;
        }

        location ~ \.php$ {
            root           /home/wwwroot/default/web;  #网站根目录
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }

首先如果遇到问题, 应该尝试看看日志, nginx是一个很成熟的软件, 有相应的日志配置 access_log, error_log 通过日志其实就能定位大部分的异常原因

再说回问题, 5xx 的问题一般都是upstream(php)的问题, 也就是php的问题, 具体到502 一般是upstream(php) 不通, 可能的原因比如你的php配置的不是9000端口, 或者php服务根本没起来.

你可以查下你的php端口或者php进程

如果是类Unix(Ubuntu / Centos...) 可以用命令
进程查询

ps -ef | grep php

端口查询

netstat -anpt | grep php | grep LISTEN
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航