Question

LAMP Stack Monitoring with Monit on Ubuntu 14.04

  • Posted January 26, 2015

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

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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.

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.

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.

Thank you.