Setup monit on Ubuntu 12.04 with VestaCP #ubuntu #vestacp

One of the things I’ve noticed VestaCP is sorely missing is automatic restarting of stopped services. Moreover, if you install VestaCP on a VPS with 1 GB RAM or less, MySQL will fail. A lot. So I setup monit to monitor and restart services. And, since I made each service its own configuration file, I thought I’d share to get anyone else up and running.

Install monit:

apt-get install monit

Super basic configuration:

nano /etc/monit/monitrc

Make sure you have a valid email on this line and make sure not commented out:

set alert your@email.com # receive all alerts

CTRL+O
CTRL+X

Put the appropriate files in /etc/monit/conf.d/ or just do the following:

cd /etc/monit/conf.d/
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/apache2.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/cron.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/dovecot.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/exim4.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/fail2ban.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/mysqld.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/nginx.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/sshd.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/vesta-nginx.conf
wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/vesta-php.conf

And if you’re on Linode, and have Longview installed, do this:

wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/longview.conf

And I had supervisord installed, so here’s that one, too. If you didn’t install it, don’t run this:

wget -c https://stevenbrady.com/wp-content/uploads/monit/12.04/supervisord.conf

Of course, once you’ve copied these in you’ll want to reload monit:

monit reload

Hopefully that went without too much trouble.

Leave a Reply

Your email address will not be published. Required fields are marked *