Nginx在所有php错误上显示403页面

时间:2015-11-27 10:56:51

标签: php amazon-web-services nginx amazon-ec2 php-5.6

我有运行nginx + php-fpm-5.6的Amazon ec2服务器

当没有错误时正确打开php页面,但是如果发生任何类型的错误(php错误或异常),它总是显示相同的页面(/test.php是请求的URL):

  

禁止

     

您无权访问此服务器上的/test.php。

     

此外,尝试时遇到403 Forbidden错误   使用ErrorDocument来处理请求。

我尝试过改变php" display_errors"选项。

当我启用它时,所有脚本开始显示403页面。在php错误日志中,我看到一条警告消息,我应该定义默认时区。当我用它定义它时 我的脚本中出现date_default_timezone_set(...); 403错误仅在脚本出现错误或我写throw new Exception();时出现。

如何将带有错误详情的正常错误消息带回文件中?

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;
    }
}

主要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;
}

0 个答案:

没有答案