【发布时间】:2017-08-07 10:45:27
【问题描述】:
我的 nginx 服务器出现问题,子文件夹下的 php 文件抛出 404 错误,但 html 文件工作正常。
文件夹结构
html<folder>
index.php
test<folder>
test.php //not working
test.html //works fine
Nginx 配置
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /var/www/html;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
}ml
当访问 <ip-address>/test/test.html 工作正常时
访问<ip-address>/test/test.php时出现404错误。
当访问<ip-address> 工作正常时(指向html/index.php 文件)。
我已经在 html 文件夹中添加了权限,也在 php.ini 文件中启用了cgi.fix_pathinfo=0。
【问题讨论】:
-
可能更适合serverfault.com。
标签: php nginx amazon-ec2