How can I make PHP display the error instead of giving me 500 Internal Server Error
Check the error_reporting
, display_errors
and display_startup_errors
settings in your php.ini
file. They should be set to E_ALL
and "On"
respectively (though you should not use display_errors
on a production server, so disable this and use log_errors
instead if/when you deploy it). You can also change these settings (except display_startup_errors
) at the very beginning of your script to set them at runtime (though you may not catch all errors this way):
error_reporting(E_ALL);
ini_set('display_errors', 'On');
After that, restart server.
Use "php -l <filename>" (that's an 'L') from the command line to output the syntax error that could be causing PHP to throw the status 500 error. It'll output something like:
PHP Parse error: syntax error, unexpected '}' in <filename> on line 18
It's worth noting that if your error is due to .htaccess, for example a missing rewrite_module, you'll still see the 500 internal server error.