HostOnNet Blog

Installing Monit On Linux CentOS Server

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

cd /usr/local/src
tar -zxvf monit-5.0.3.tar.gz
cd monit-5.0.3
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/
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host 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


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

Posted in Linux