Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Could you append a part of the error log? – Christopher Perrin Aug 13 '12 at 18:41
This is the entire error log: – James Linton Aug 13 '12 at 18:44
This is indeed not very helpful :-/ – Christopher Perrin Aug 13 '12 at 18:47
Related:… – Kzqai Jul 21 '15 at 16:55
up vote 4 down vote accepted

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!

share|improve this answer

php-fpm throws everything in /var/log/php5-fpm.log or similar.

share|improve this answer
That log just shows this: [13-Aug-2012 20:15:54] NOTICE: fpm is running, pid 10599 [13-Aug-2012 20:15:54] NOTICE: ready to handle connections [13-Aug-2012 20:18:37] NOTICE: Finishing ... [13-Aug-2012 20:18:37] NOTICE: exiting, bye-bye! [13-Aug-2012 20:18:39] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful – James Linton Aug 13 '12 at 18:39
Try to set `error_log to something. As php-fpm with nginx doesn't work as it works with apache2. – erickzetta Aug 13 '12 at 18:41
The PHP-FPM log is just about errors of PHP-FPM. You can enable PHP logging seperately in your php.ini – Christopher Perrin Aug 13 '12 at 18:41
Or check… – erickzetta Aug 13 '12 at 18:43

Look in your nginx.conf for an error_log definition. Maybe nginx writes something in this error log.

You might also enable logging to file on PHP.

share|improve this answer
I looked in the file that error_log is set to, and it's empty. No errors at all. – James Linton Aug 13 '12 at 18:39

For me, this seemed to be a problem with upstart, which was routing the logs for php-fpm to it's own custom location, e.g.:


There's also some bugginess with ubuntu Precise, 12.04 that may contribute to the lack of logging ability: If you're still running that version.

share|improve this answer

When PHP display_errors are disabled, PHP errors can return Nginx 500 error.

You should take a look to your php-fpm logs, i'm sure you'll find the error there. With CentOS 7 :

tail -f /var/log/php-fpm/www-error.log

You can also show PHP errors. In your php.ini, change :

display_errors = Off

to :

display_errors = On

Hope it helps.

share|improve this answer

This is what happened to me:

When I deleted my error log, nginx noticed that it was no longer missing. When I recreated this file nginx would no longer recognise that it existed, therefore not writing to the file.

To fix this, run these commands (I'm on Ubuntu 14.04 LTS):

sudo service nginx reload

If that doesn't work, then try:

sudo service nginx restart
share|improve this answer
That is so completely not how nginx logging, or Unix file handling, works... – womble Aug 12 '15 at 7:53
It fixed it for me, so I'm not complaining – mightyspaj Aug 12 '15 at 8:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.