Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Fall Back When PHP Fails

I was wondering if anybody knew of a method to configure apache to fall back to returning a static HTML page, should it (Apache) be able to determine that PHP has died? This would provide the developer with a elegant solution to displaying an error page and not (worst case scenario) the source code of the PHP page that should have been executed.

Thanks.

like image 918
Kieran Hall Avatar asked Dec 18 '22 10:12

Kieran Hall


1 Answers

The PHP source code is only displayed when apache is not configured correctly to handle php files. That is, when a proper handler has not been defined.

On errors, what is shown can be configured on php.ini, mainly the display_errors variable. That should be set to off and log_errors to on on a production environment.

If php actually dies, apache will return the appropriate HTTP status code (usually 500) with the page defined by the ErrorDocument directive. If it didn't die, but got stuck in a loop, there is not much you can do as far as I know.

You can specify a different page for different error codes.

like image 81
Vinko Vrsalovic Avatar answered Feb 03 '23 20:02

Vinko Vrsalovic