为什么nginx访问“ index.php”文件时显示“找不到文件”消息?

问题描述

我在线上遇到了许多类似的问题,但是没有一个解决方案有效。诚然,我对内部工作原理的理解是有限的,但是我确实知道我当前的nginx配置已经工作了几个月,直到昨天晚上。

server {
    index index.html index.php;
    server_name XXX.xxx;
    root /var/www/ZZZ/;

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

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

}

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;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...