get an email when web server has a 500 error

pkromer
pkromer used Ask the Experts™
on
Is it possible to set up a script on an Apache web server to email me whenever a 500 error happens? How would I do that? We use Symfony and if there's a code failure I want to know about it bright away... the Symfony logs don't show a 500 error but the server logs do.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fractional CTO
Distinguished Expert 2018
Commented:
1) Use Fail2ban.

2) Write a recipe to track /var/log/apache2/access.log (or error.log) looking for 500s.

3) When one occurs, send email to a notification list.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Fail2Ban == One of the great unknown work horses of the Internet.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
@pkromer, if you have any problems accomplishing this, open another question about...

"How to use Fail2Ban to catch Apache 500 errors, then email a notification list."
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Turns out my web host (Pair Networks) already has Fail2ban installed on our dedicated server, they do that for security purposes. Im asking them to create a mail rule. Thanks for pointing it out, looks like a really good thing to have on the server.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Perfect!

You're welcome!

Once the create the Fail2Ban recipe for you, have them send you a copy, so you can keep it on file for when you change hosting.

Author

Commented:
well crap, my web hosts copy cant be used for this, so I have to install my own copy to do this. Ill open another question per your suggestion above.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial