Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a development server and I would like to configure Apache so that when a 500 http code is generated it will display the error directly in the response (i.e. what would be printed to /var/log/httpd/error_log is displayed to the user).

However, I cannot figure out where this directive is.

Any help?

share|improve this question
add comment

2 Answers

Set up Apache to use server-side includes (.shtml files) and configure a custom error page as above (though naturally pointing to an .shtml file), and in that custom error page use something like this:

<p>The requested page, <code>
<!--#echo var="REQUEST_URI" --></code>,
 does not work properly.</p>

<p>Click <a href='<!--#echo var="HTTP_REFERER" -->'>here</a> to return from whence you came.</p>

<fieldset>
<legend>Error Message</legend>
<xmp>
<!--#echo var="REDIRECT_ERROR_NOTES" -->
</xmp>
</fieldset>

<!--
<!--#echo var="HTTP_USER_AGENT" -->
<!--#echo var="REDIRECT_STATUS" -->
-->
share|improve this answer
add comment

I believe the directive you are looking for is ErrorDocument (documented here). For example:

<VirtualHost *:80>
    ...

    ErrorDocument 500 /error/500.html
</VirtualHost>

On a second read-through of your question it appears you may be asking for Apache to display the error directly in the browser (i.e. what would appear in /var/log/httpd/error_log). Can you clarify?

share|improve this answer
    
Hi. Your second guess is the one I am interested in. I want it to print the error to the browser, not a custom error page. Thanks –  Thomas Feb 21 '12 at 14:44
    
It is amazing how a seemingly easy question, has no responses. –  Thomas Feb 21 '12 at 15:59
1  
This isn't seemingly easy as it represents a complex change in how Apache normally handles these errors. I can appreciate how frustrating it can be to not get immediate assistance from volunteers during their work day... –  Kyle Smith Feb 21 '12 at 16:04
1  
@Thomas As far as I'm aware there's no way to do this without putting it together yourself with dynamic code in a custom 500 handler page. I can't blame Apache for not building it in, either - having this on a production web server would be reckless information disclosure, while using it for debugging seems pointless since the error log is easily tail-able. –  Shane Madden Feb 21 '12 at 16:28
    
OK guys. Thanks. @Kyle. I was not being cynical. It was just an observation –  Thomas Feb 21 '12 at 16:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.