I have some server applications running on apache2; Ruby on Rails, PHP and others.
In all cases I would like apache to send me an email whenever apache responds a HTTP error 500 Internal server error.
How can I do that?
You can create a custom 500 file. Assuming you are using Apache you would add the following line to your .htaccess
This code basically tells the server that if a user encounters a 500(internal server error) Error to display errorfilename.php.
In this PHP file you can add code to email you when a user gets to the 500.
You can use the ErrorDocument directive to deliver a custom error message, and make that file a script that sends the e-mail. Alternatively, write the error page so that it writes a file with whatever information you want and set up a cron job to mail these files to you.