我已经使用nginx
+ 安装了测试服务器php-fpm
。我已经尝试了以下所有方法:
nginx + php fpm-> 404 php页面-找不到文件
总结一下我尝试过的:
- 重新安装。
- 更改脚本特权(将其更改为
0777
)。 fastcgi_intercept_errors on
。- 检查
root
指令的层次:server
,location
和location ~ \.php
。 - 检查
fastcgi_param SCRIPT_FILENAME
指令。
服务器在(且仅在).php
脚本上返回404 。我可以将它们重命名为.html
,就可以了。我该怎么办?
这是我的nginx.conf
:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 2;
include /etc/nginx/conf.d/*.conf;
index index.html index.htm;
server {
listen 80;
server_name _;
root /var/www/html;
location / {
root /var/www/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
#root /var/www/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
#root /var/www/html;
}
location ~ \.php$ {
root /var/www/html;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}