Nginx not logging PHP errors
When accessing some PHP scripts on my website, I'm getting the dreaded 500 error message. I'd like to know what's wrong to fix it, but Nginx isn't logging any PHP errors in the log file I have specified. This is my server block:
server {
listen 80;
server_name localhost;
access_log /home/whitey/sites/localhost/logs/access.log;
error_log /home/whitey/sites/localhost/logs/error.log error;
root /home/whitey/sites/localhost/htdocs;
index index.html index.php /index.php;
location / {
}
location ~ \.php$ {
fastcgi_pass unix:/tmp/phpfpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
}
}
Note that some PHP scripts work fine, and others don't. So there isn't a global problem with PHP, there's just something in these scripts that's causing Nginx to throw the 500 error.
How can I get to the bottom of this? The only thing in error.log
is an error about favicon.ico not being found.
You have to add the following to your php-fpm pool configurations:
catch_workers_output = 1
You have to add this line to each defined pool!
I had a similar issue.
I tried deploy phpMyAdmin with php-fpm 7.0 and nginx on CentOS7. Nginx showed me 500.html but there was not errors in any log file. I did all of this
catch_workers_output = 1
and
display_errors = On
Either nginx log or php-fpm log did not contained any error string.
And when I commented this line in nginx.conf I was able to see in browser page things that was wrong.
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
That was what helped me understand troubles.
php-fpm
throws everything in /var/log/php5-fpm.log
or similar.