I'm wondering if anybody understood of a means to configure apache to fall to coming back a static HTML page, should it (Apache) have the ability to determine that PHP has died? This could supply the developer having a elegant means to fix exhibiting a mistake page and never (worst situation scenario) the origin code from the PHP page which should happen to be performed.

Thanks.

The PHP source code is just displayed when apache isn't set up properly to deal with php files. That's, whenever a proper handler is not defined.

On errors, what's proven could be set up on php.ini, mainly the display_errors variable. That needs to be set to off and log_errors to on on the production atmosphere.

If php really dies, apache will return the right HTTP status code (usually 500) using the page based on the ErrorDocument directive. Whether it did not die, but got stuck inside a loop, there's very little that you can do so far as I understand.

You are able to specify another page for various error codes.

I'd think that this typically produces a 500 error, and you will configure apaches 500 handler to exhibit a static page:

ErrorDocument 500 /500error.html

You may also find out about error handlers on apaches documentation site

The actual issue is that PHP fatal errors don't cause Apache to come back a 500 code. Errors aside from E_FATAL and E_PARSE can be remedied any way you like using set_error_handler().

You will find two ways to user PHP and apache. 1. Install PHP being an Apache module: by doing this the php execution is really a thread within the apache process. therefore if php execution fails, the apache process fails. there's no fallback strategy. 2. Install PHP like a CGI script handler: by doing this apache will begin a brand new PHP process for every request. I the PHP execution fails, apache knows might there can be a method to handle the mistake. no matter how you install PHP, when PHP execution fails, you are able to handle erros within the php.ini file.

AdamTheHutt is correct, a minimum of this is exactly what I've observed with Debian, Apache2 and mod_php. As the PHP may return a 500 Server error, this really is set from inside PHP, not Apache. Hence Apache doesn't apply the ErrorDocument 500 option. ErrorDocument works when PHP can be used with Apache via CGI. I haven't found a appropriate way of re-exhibiting these errors.

A potential solution is by using register_shutdown_work as listed at: How do you catch a php fatal error