Nginx在所有php错误上显示403页
我有运行nginx+php-fpm-5.6的amazonec2服务器 当没有错误时,它会正确打开php页面,但如果出现任何类型的错误(php错误或异常),它总是显示相同的页面(Nginx在所有php错误上显示403页,php,amazon-web-services,nginx,amazon-ec2,php-5.6,Php,Amazon Web Services,Nginx,Amazon Ec2,Php 5.6,我有运行nginx+php-fpm-5.6的amazonec2服务器 当没有错误时,它会正确打开php页面,但如果出现任何类型的错误(php错误或异常),它总是显示相同的页面(/test.php是请求的url): 禁止 您没有在此服务器上访问/test.php的权限 此外,尝试执行时遇到403禁止的错误 使用ErrorDocument来处理请求 我尝试更改php的“显示错误”选项 当我启用它时,所有脚本开始显示403页。在php错误日志中,我看到一条警告消息,我应该定义默认时区。当我用 date
/test.php
是请求的url):
禁止
您没有在此服务器上访问/test.php的权限
此外,尝试执行时遇到403禁止的错误
使用ErrorDocument来处理请求
我尝试更改php的“显示错误”选项
当我启用它时,所有脚本开始显示403页。在php错误日志中,我看到一条警告消息,我应该定义默认时区。当我用
date\u default\u timezone\u set(…)代码>在我的脚本403中,只有当脚本有错误或我编写抛出新异常()时,错误才会出现代码>例如
我如何带回包含错误详细信息的正常错误消息,并将其放在发生错误的文件中
Upd。我的nginx配置:
server {
listen 80 default_server;
server_name localhost;
root /var/www/html;
index index.php index.html;
client_max_body_size 200m;
access_log /var/log/nginx/admin.xuno.com.au.access.log;
error_log /var/log/nginx/admin.xuno.com.au.error.log;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
proxy_read_timeout 120;
}
}
Main nginx.conf
user dev-user;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/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;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
你能更新你的问题并添加一个nginx
配置文件吗?@RichardSmith:我已经添加了。我无法复制403。您确定用户dev user可以读取/var/www/html
?我注意到两个小问题(但不相关),location regex应该是\.php$
(缺少反斜杠),您需要try\u files$uri=404代码>在同一个位置,以确保脚本文件存在。在我的本地机器上,我有相同的配置,一切都很好。我已经修改了你的通知,但没有任何改变。该文件夹及其所有内容属于dev user:dev user。