02 December 2017

Slim (PHP) and HTTP ERROR 500, Internal Server Error

When starting out with Slim, sometimes people have difficulty getting it running and their browser returns a HTTP ERROR 500, Internal Server Error. There can be many reasons for this and the error message itself isn’t very helpful. To track down the issue, look in your error log. You will find a more detailed message indicating where the problem is.

Where is the error log? Using Apache, there are a few ways you can find the error log. In the httpd.conf file look for the ErrorLog directive. Typically it will be in logs/error_log, with respect to Apache’s installation. If your hosting setup doesn’t allow you to peek there (get new hosting) you can also use PHP to tell you where it is. You can echo phpinfo(); and look for “error_log” under ‘Core’, or get it directly with PHP.

echo ini_get('error_log');

Once you have the location of the error log, open the log and you should see a more helpful error message.