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