HostOnNet Blog

Installing Monit On Linux CentOS Server

Looking for Linux Server Admin or WordPress Expert? We can help.

monit is an open source software that monitor services on your server. It can restart if any of the service go down.

Download latest version of file from

http://mmonit.com/monit/download/

cd /usr/local/src
wget http://mmonit.com/monit/dist/monit-5.0.3.tar.gz
tar -zxvf monit-5.0.3.tar.gz
cd monit-5.0.3
./configure
make
make install

Copy control file to /etc

cp monitrc /etc/

Edit /etc/monitrc

vi /etc/monitrc

At the end of the file add or uncomment

include /etc/monit.d/*

Now to monitor Apache, create a file /etc/monit.d/apache

vi /etc/monit.d/apache

Add following content

check process httpd with pidfile /var/run/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host 127.0.0.1 port 80 protocol http
   and request "/phpinfo.php"
   then restart
if 5 restarts within 5 cycles then timeout

You can change

and request "/phpinfo.php"

To any file on your web server. I do have a phpinfo file on my server, so i used it.

Some says phpinfo.php is a security risk, to me it is only a security risk if you run vlunerable application on your web server. If you use update software on your server, some one seeing your phpinfo is not a security issue.

To run monit, edit /etc/rc.local

vi /etc/rc.local

Add

/usr/local/bin/monit -d 60 -v -c /etc/monitrc  -p /var/run/monit.pid -l /var/log/monit.log

Posted in Linux

One Response to Installing Monit On Linux CentOS Server

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.