php - 为什么 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;
解决方案
推荐阅读
- html - 为什么 div 位置在不同的语言环境中发生变化?
- javascript - 将函数映射到数组时,GAS 导致“参数与方法签名不匹配”异常
- vb.net - 在用户回答多项选择题后,如何让我的程序在 vb.net 中继续下一个问题?
- android - 当应用程序在后台运行时,Android Listener 停止运行
- crop - 如何基于掩码裁剪所有对象,Mask-RCNN
- jmeter - 如何在 JSON POST 请求中关联两个变量
- c++ - 不同概念的 C++ 不同 using 声明
- amazon-web-services - HTML 无法访问 Amazon S3 存储桶 css 和 js 文件夹
- javascript - 为什么我的对象中的属性值重复?
- python - 如何在课堂上的一个函数中使用 celery 进度条?