I have internal server errors on my POST requests. How can I debug them ? Is it something to set up in php.ini ? THe file is really big and the word 'error' is met there many-many times.
Asked
Active
Viewed 1.4e+01k times
48
-
Turn on your php errors. – Rikesh Mar 04 '14 at 11:38
-
Start from up to down and resolve with first error you encounter. – Rohit Awasthi Mar 04 '14 at 11:39
-
Check the above link. It has almost all in it what you need. – Rikesh Mar 04 '14 at 11:39
-
For me its not a PHP error, for some reasons its showing server error of 500. – Duke Mar 23 '17 at 05:18
2 Answers
80
You can turn on your PHP errors with error_reporting
:
error_reporting(E_ALL);
ini_set('display_errors', 'on');
Edit: It's possible that even after putting this, errors still don't show up. This can be caused if there is a fatal error in the script. From PHP Runtime Configuration:
Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.
You should set display_errors = 1
in your php.ini
file and restart the server.

Devon Bessemer
- 34,461
- 9
- 69
- 95

Philippe Signoret
- 13,299
- 1
- 40
- 58
-
And I will see errors in the browser console, right ? I think I dont see them now, though i managed my php.ini file. – myadmins Mar 04 '14 at 11:50
-
1
-
What platform/stack are you using? (Windows/Linux? Apache/IIS?) – Philippe Signoret Mar 04 '14 at 11:51
-
I'm using linux + apache + firefox. No errors in the browser yet. Only error 500 in console. – myadmins Mar 04 '14 at 11:53
-
2
-
-
Then you probably have an error in the script preventing runtime from even getting to these lines. You should update you `php.ini` file to include `display_errors = 1`, and restart the server. (Answer updated to show this.) – Philippe Signoret Mar 04 '14 at 12:04
-
OOPS I forgot to restart the server, guys, reaally thank you, topic is closed. PS I never expected to recieve so fast flash help. – myadmins Mar 04 '14 at 12:07
-
1If you cannot modify php.ini, just add this in a .htaccess file: `php_flag display_errors 1` – Tom Jan 16 '19 at 10:56
29
Try writing all the errors to a file.
error_reporting(-1); // reports all errors
ini_set("display_errors", "1"); // shows all errors
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
Something like that.

James Elliott
- 1,012
- 9
- 20
-
-
1@myadmins yes, before anything else. You could also set this in php.ini. – James Elliott Mar 04 '14 at 11:49