How can i make php display the error instead of giving me 500 internal server error?

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?

asked Apr 22, 2010 at 1:45

1

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.

How can i make php display the error instead of giving me 500 internal server error?

Davide

1,5751 gold badge14 silver badges29 bronze badges

answered Apr 22, 2010 at 1:49

awgyawgy

16.2k4 gold badges24 silver badges18 bronze badges

7

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

How can i make php display the error instead of giving me 500 internal server error?

Matthew Lock

12.4k11 gold badges89 silver badges128 bronze badges

answered May 25, 2016 at 3:53

AaronAaron

5535 silver badges12 bronze badges

3

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.

answered Aug 4, 2014 at 1:53

dtbarnedtbarne

8,0335 gold badges42 silver badges48 bronze badges

1

Be careful to check if

display_errors

or

error_reporting

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

display_errors = on;

So remember the last one counts!

answered Sep 9, 2016 at 15:17

How can i make php display the error instead of giving me 500 internal server error?

MaxMax

2,39921 silver badges26 bronze badges

Try not to go

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

but

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

and change it there, it worked for me...

answered Mar 20, 2017 at 20:57

How can i make php display the error instead of giving me 500 internal server error?

Enabling error displaying from PHP code doesn't work out for me. In my case, using NGINX and PHP-FMP, I track the log file using grep. For instance, I know the file name mycode.php causes the error 500, but don't know which line. From the console, I use this:

/var/log/php-fpm# cat www-error.log | grep mycode.php

And I have the output:

[04-Apr-2016 06:58:27] PHP Parse error:  syntax error, unexpected ';' in /var/www/html/system/mycode.php on line 1458

This helps me find the line where I have the typo.

answered Apr 4, 2016 at 5:05

Hao NguyenHao Nguyen

5184 silver badges9 bronze badges

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)

answered Mar 6, 2017 at 12:16

How can i make php display the error instead of giving me 500 internal server error?

How do I get rid of 500 internal server error?

How to Fix the 500 Internal Server Error.
Reload the web page. ... .
Clear your browser's cache. ... .
Delete your browser's cookies. ... .
Troubleshoot as a 504 Gateway Timeout error instead. ... .
Contacting the website is another option. ... .
Come back later..

Why do I keep getting 500 internal server error?

The 500 Internal Server error could be caused by an error during the execution of any policy within Edge or by an error on the target/backend server. The HTTP status code 500 is a generic error response. It means that the server encountered an unexpected condition that prevented it from fulfilling the request.

What causes 500 errors PHP?

PHP Coding Timing Out If your PHP script makes external network connections, the connections may time out. If too many connections are attempted and time out, this will cause a "500 Internal Server Error." To prevent these time outs and errors, you'll want to make sure that PHP scripts be coded with some timeout rules.

How can I get Internal server error in PHP?

Below are common troubleshooting steps that can be taken to resolve a 500 Internal Server Error:.
Check the error logs..
Check the . htaccess file..
Check your PHP resources..
Check CGI/Perl scripts..