<p>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.</p>

<p>Thanks.</p>

[{'answer_id': 62016, 'author': 'Staale', 'author_id': 3355, 'author_profile': 'https://Stackoverflow.com/users/3355', 'pm_score': 2, 'selected': False, 'text': '<p>I would assume that this typically results in a 500 error, and you can configure apaches 500 handler to show a static page:</p>\n\n<p>ErrorDocument 500 /500error.html</p>\n\n<p>You can also read about error handlers on <a href="http://httpd.apache.org/docs/2.0/custom-error.html" rel="nofollow noreferrer">apaches documentation site</a></p>\n'}, {'answer_id': 62019, 'author': 'Vinko Vrsalovic', 'author_id': 5190, 'author_profile': 'https://Stackoverflow.com/users/5190', 'pm_score': 4, 'selected': True, 'text': "<p>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. </p>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>You can specify a different page for different error codes.</p>\n"}, {'answer_id': 62748, 'author': 'AdamTheHutt', 'author_id': 1103, 'author_profile': 'https://Stackoverflow.com/users/1103', 'pm_score': 1, 'selected': False, 'text': '<p>The real problem is that PHP fatal errors don\'t cause Apache to return a 500 code. Errors except for <code>E_FATAL</code> and <code>E_PARSE</code> can be handled however you like using <a href="http://www.php.net/set_error_handler" rel="nofollow noreferrer"><code>set_error_handler()</code></a>.</p>\n'}, {'answer_id': 65988, 'author': 'farzad', 'author_id': 9394, 'author_profile': 'https://Stackoverflow.com/users/9394', 'pm_score': 0, 'selected': False, 'text': '<p>There are 2 ways to use PHP and Apache.</p>\n\n<pre><code>1. Install PHP as an Apache module: this way the PHP execution is a thread inside the apache process. So if PHP execution fails, then Apache process fails too. there is no fallback strategy.\n\n2. Install PHP as a CGI script handler: this way Apache will start a new PHP process for each request. If the PHP execution fails, then Apache will know that, and there might be a way to handle the error.\n</code></pre>\n\n<p>regardless of the way you install PHP, when PHP execution fails you can handle errors in the <code>php.ini</code> file.</p>\n'}]
['https://Stackoverflow.com/questions/62012', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6085/']