我的 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 文件夹中添加了权限,也在cgi.fix_pathinfo=0
php.ini 文件中启用。
server {
listen 80;
server_name localhost;
root /var/www/html;
autoindex on;
location / {
index index.php index.html;
}
location ~\.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri $uri/ /index.php;
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句