Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When PHP Fatal error happens, Nginx reports HTTP Error 500 to browser

Tags:

php

nginx

fastcgi

My server is setup with Nginx + PHP + FastCGI. Whenever PHP throws a Fatal error, it gets logged inside of nginx/error.log, but the server reports HTTP Error 500 back to the browser instead of displaying the PHP Fatal error to the browser as is desired and typical in other setups. I've been searching for how to resolve this and keep coming up short. Anyone have anything helpful about this? Much appreciated!

like image 904
OCDev Avatar asked Jan 20 '23 05:01

OCDev


2 Answers

Found it!

As of PHP 5.2.4, the default is now to cause a 500 error, because the alternative is an empty page.

Other discussions suggest that this behavior can not be changed for the "PHP Fatal" error type, which don't flow through the normal error handler routines and can not be caught or stopped.

like image 139
Charles Avatar answered May 02 '23 20:05

Charles


You probably have php_errors off (or the displaying of them) in your php loader script... Try checking your php.ini settings...

like image 45
Gekkie Avatar answered May 02 '23 18:05

Gekkie