Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 internal server error, how to debug [duplicate]

Tags:

php

debugging

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.

like image 746
myadmins Avatar asked Mar 04 '14 11:03

myadmins


People also ask

How do I fix a 500 Internal server error?

Clear your browser cache and cookies Check these articles on deleting the cache on an Android phone or iPhone, if you use a mobile device. Alternatively, you can test opening the page from another browser. For instance, if you use Chrome, try Firefox or vice versa.


2 Answers

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.

like image 91
Philippe Signoret Avatar answered Sep 21 '22 02:09

Philippe Signoret


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.

like image 29
James Elliott Avatar answered Sep 21 '22 02:09

James Elliott