Nginx – Getting Fatal Errors in Nginx to Be Shown in the Browser

nginxwebweb-server

While developing I'm getting blank pages in my browser whenever I create a fatal error in PHP with a typo or just my bad programming ;). It's super annoying for me to have to view the raw nginx error log file to see the fatal errors and find the line numbers where they are. I can't seem to find how to make nginx display PHP fatal errors in the browser. Here is the relevant part of my nginx config:

location @fpm {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_NAME index.php;
    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
    fastcgi_param PATH_INFO $path_info;
}

Here's an example error that shows up in my error log and then results in a blank browser page:

2014/01/04 14:53:52 [error] 20082#0: *403 FastCGI sent in stderr:
"PHP message: PHP Fatal error:  Cannot redeclare class ClassName in FilePath on line 356"
while reading response header from upstream, client: 192.168.1.10,
server: servername, request: "GET URLPATH HTTP/1.1",
upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "host",
referrer: "referer"

Here is my PHP info:

enter image description here

Here is my PHP-FPM conf:

http://pastebin.com/QkCTbBYj

And my PHP-FPM pool conf:

http://pastebin.com/TZfZ8d7G

And my PHP-FPM php.ini:

http://pastebin.com/RsXRxduf

I would love if anyone could shed some light on what I could do to get these errors to show up!

Best Answer

In your PHP-FPM Pool config uncomment

line 463 php_flag[display_errors] = off

and change it to

php_flag[display_errors] = on

and don't forget to restart php-fpm