dscrn1974 2015-11-27 10:56
浏览 250

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

I have Amazon ec2 server running nginx + php-fpm-5.6

It opens php pages correctly when there are no errors, but if any kind of error occurs (php error or exception) it always displays the same page (/test.php is the requested url):

Forbidden

You don't have permission to access /test.php on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I tried changing php "display_errors" option.

When I enable it all scripts begin to show 403 page. In php error log I see a warning message that I should define default timezone. When I define it with date_default_timezone_set(...); in my scripts 403 error goes and appears only when a script has some mistake or if I write throw new Exception(); for example.

How can I bring back normal error messages with details of an error and place in file where it has occured?

Upd. My nginx configuration:

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;
}
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记