Software⏱️ 3 min read📅 2026-06-03

How to Fix: How can I make PHP display the error instead of giving me 500 Internal Server Error

Display PHP error messages instead of a 500 Internal Server Error.

Quick Answer: Enable display_errors in your php.ini file to show the actual error message.

PHP displays error messages instead of a 500 Internal Server Error, which can be frustrating for developers and administrators. This issue affects anyone using PHP on a server that is configured to display error messages as internal server errors.

This problem has become tedious due to the need to transfer files between servers to find the error, wasting time and effort. In this guide, we will explore possible causes of this issue and provide steps to fix it.

🔍 Why This Happens

  • The primary cause of PHP displaying error messages as internal server errors is the use of the 'display_errors' directive in the php.ini file being set to 'Off'. This directive controls whether or not PHP displays error messages on the screen. When this directive is enabled, PHP will display the error message instead of sending a 500 Internal Server Error response.
  • Another possible cause is the server's configuration, specifically the Apache settings. If the 'ErrorLog' and 'LogColor' directives are not properly configured, it can lead to PHP displaying error messages as internal server errors.

🚀 How to Resolve This Issue

Enabling display_errors in php.ini

  1. Step 1: Open the php.ini file located in the root directory of your server (usually /etc/php.ini or /usr/local/etc/php.ini).
  2. Step 2: Locate the 'display_errors' directive and change its value from 'Off' to 'On'. This will enable PHP to display error messages on the screen.
  3. Step 3: Save the changes to the php.ini file and restart Apache by running the command '/service apache2 restart' or '/service httpd restart', depending on your server configuration.

Configuring ErrorLog and LogColor in Apache

  1. Step 1: Open the Apache configuration file located in the /etc/apache2/apache2.conf file (or /etc/httpd/conf.d/httpd.conf for HTTP servers).
  2. Step 2: Add or modify the 'ErrorLog' directive to point to a log file where error messages will be written. For example, add the following line: ErrorLog /var/log/apache2/error.log'.
  3. Step 3: Also, modify the 'LogColor' directive to specify the color of the error message. For example, add the following line: LogColor #0000FF'.
  4. Step 4: Save the changes and restart Apache by running the command '/service apache2 restart' or '/service httpd restart', depending on your server configuration.

💡 Conclusion

By following these steps, you should be able to fix the issue of PHP displaying error messages as internal server errors. Remember to always check your php.ini file and Apache configuration for any other potential issues that may be causing the problem.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions