Setting up monit on Ubuntu

How to set up monit on Linux

sudo aptitude install monit

sudo nano /etc/monit/monitrc

Make sure to change the default apache location to:

check process apache with pidfile /var/run/apache2.pid
    start program = "/etc/init.d/apache2 start" with timeout 60 seconds
    stop program  = "/etc/init.d/apache2 stop"

and here are the additional lines I comment out / add:

set daemon  60
set logfile /var/log/monit.log
set mailserver localhost
set alert sjobs@apple.com

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 host 127.0.0.1 port 3306 protocol mysql for 2 cycles then restart
  if 5 restarts within 5 cycles then timeout

Thanks to mattmcman.us for help with this.