Coder Perfect

How can I get PHP to show the problem rather than returning 500 Internal Server Error [duplicate]?


Nothing like this has ever happened before. Normally, the error is displayed, but now I merely get a 500 internal server error. Previously, when the error was displayed, it was on various servers. I’m now on a different server (I have full root, so if I need to configure it somewhere in the php.ini, I can.) Maybe it’s anything to do with Apache?

I’ve been putting up with it by uploading the file to my other server and running it there to identify the error, but it’s getting old. Is there a way to get this to work?

Asked by Rob

Solution #1

In your php.ini file, look at the error reporting, display errors, and display startup errors options. They should be set to E ALL and “On,” respectively (however display errors should not be used on a production server, so disable it and use log errors instead if/when you deploy it). These options (except display startup errors) can also be changed at the start of your script to set them at runtime (though you may not catch all errors this way)

ini_set('display_errors', 'On');

Restart the server after that.

Answered by awgy

Solution #2

To print the syntax mistake that may be causing PHP to produce the status 500 error, run php -l filename> (that’s a ‘L’) from the command line. It’ll say something like this:

Unexpected ” in filename> on line 18 causes a PHP parse error.

Answered by Aaron

Solution #3

It’s worth mentioning that if your error is caused by.htaccess, such as a missing rewrite module, the 500 internal server error will still appear.

Answered by dtbarne

Solution #4

Make sure you double-check to see if




someplace else in the ini file is active (not a comment).

After upgrading to Kubuntu 16.04, my development server refused to report errors – I examined php.ini several times and discovered a diplay errors = off; roughly 100 lines below my code.

display_errors = on;

So remember the last one counts!

Answered by Max

Solution #5

Make an effort not to go.

MAMP > conf > [your PHP version] > php.ini


MAMP > bin > php > [your PHP version] > conf > php.ini

It worked for me if I changed it there…

Answered by von verletzt

Post is based on