This question already has an answer here:
- PHP's white screen of death 15 answers
This has never happened before. Usually it displays the error, but now it just gives me a 500 internal server error. Of course before, when it displayed the error, it was different servers. Now I'm on a new server (I have full root, so if I need to configure it somewhere in the php.ini, I can.) Or perhaps its something with Apache?
I've been putting up with it by just transferring the file to my other server and running it there to find the error, but that's become too tedious. Is there a way to fix this?
Check the
error_reporting
,display_errors
anddisplay_startup_errors
settings in yourphp.ini
file. They should be set toE_ALL
and"On"
respectively (though you should not usedisplay_errors
on a production server, so disable this and uselog_errors
instead if/when you deploy it). You can also change these settings (exceptdisplay_startup_errors
) at the very beginning of your script to set them at runtime (though you may not catch all errors this way):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.
Be careful to check if
or
is active (not a comment) somewhere else in the ini file.
My development server refused to display errors after upgrade to Kubuntu 16.04 - I had checked php.ini numerous times ... turned out that there was a diplay_errors = off; about 100 lines below my
So remember the last one counts!
If all else fails try moving (i.e. in bash) all files and directories "away" and adding them back one by one.
I just found out that way that my .htaccess file was referencing a non-existant .htpasswd file. (#silly)
Try not to go
but
and change it there, it worked for me...