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?
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
ErrorDocument 500 /errorfilename.php
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.
<?php
//this is the 500 error php file
mail(ma@me.com,500 error encountered,'message here');
?>
<html>
<head>
<title>500</title>
<body>
500 internal server error
The administrator has been notified
<a href="index.php">Go to Homepage</a>
</body>
</html>
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.