tokar93
By:
tokar93

LAMP Stack Monitoring with Monit on Ubuntu 14.04

January 26, 2015 2.9k views

Hi

How can i get this guide to work whit Apache instead of nginx?

https://www.digitalocean.com/community/tutorials/lemp-stack-monitoring-with-monit-on-ubuntu-14-04

2 Answers

Much of that article applies to using Monit on any server, whether it runs Nginx or not. Installing Monit, setting up email notifications, and setting up system check like disk usage will all be the same. The one difference is the file you create named /etc/monit/conf.d/lemp-services in the tutorial.

Instead of looking at the Nginx process, you'll want to change to something like this:

check process apache with pidfile /var/run/apache2/apache2.pid
    group www-data
    start program = "/etc/init.d/apache2 start"
    stop program = "/etc/init.d/apache2 stop"
    if failed host example.com port 80 protocol http then restart
    if 5 restarts within 5 cycles then timeout

check process mysql with pidfile /var/run/mysqld/mysqld.pid
    start program = "/etc/init.d/mysql start"
    stop program = "/etc/init.d/mysql stop"
    if failed unixsocket /var/run/mysqld/mysqld.sock then restart
    if 5 restarts within 5 cycles then timeout

This will check that both Apache and MySql are up and running, and restart them if needed. Make sure to replace example.com with your domain or IP address.

  • You might want to rename that process name from nginx to apache2 at line 1 just after check process to avoid duplicated names problems if you actually want to monitor nginx at the same time.

  • @chrisben Sorry about that. Just cargo culted that over when adopting the Nginx example from the article. Updated above.

Have another answer? Share your knowledge.