Apache does not want to display a custom error document that I have setup.

In my vhost I have

    DocumentRoot /var/www/site/public
    ErrorDocument 500 /500.html

The 500.html is located in /var/www/site/public/500.html

To test this I have just created a broken php page that does return a 500 header but the page is blank. I suspect that this is a result of php generating the 500 page and not apache. So how do I get php to show my custom apache error document?

1 Answer 1


This is normal behavior, as PHP errors aren't considered 5xx Server Errors. According to RFC 7231

6.6. Server Error 5xx

The 5xx (Server Error) class of status code indicates that the server is aware that it has erred or is incapable of performing the requested method. - -

6.6.1. 500 Internal Server Error

The 500 (Internal Server Error) status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

PHP errors should always be fixed as they may pose you security problems. For the same reason best practise in handling php errors is to log them for the programmers to review and hide them from users. This kind of setup would be (in php.ini format):

error_reporting = E_ALL
log_errors = On
display_errors = Off

This will log errors in web server's error log or in other error log configured. Instead of reading them from the site you can perform tail -f on the log file during loading the page.

  • 1
    This answer makes no sense. One cannot "fix" an error the same instant it occurred. And setting display_errors to off will trigger the very 500 error that this very question is about. Sep 8, 2017 at 13:46
  • The error will be in logs... where it should be. Sep 8, 2017 at 13:48
  • The question here IS NOT about where the text of the error message should be but what should be displayed to a site user. There are some strange people that are browsing your site, you know Sep 8, 2017 at 13:49
  • PHP will show blank page / section, depending on the case. This answer is from 2015. At least back then there weren't any 5xx errors regarding errors in PHP syntax. Sep 8, 2017 at 13:52
  • 1
    I will. But when I see a hosting provider support referencing this answer... WTF? Sep 8, 2017 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .