Install Monit to serve Nginx

Build to explore
Aug 9, 2017 · 1 min read

Monit is open source. It automatically monitors and manages server process, files, directories, checksums, permissions, filesystems and services like Apache, Nginx, MySQL, FTP, SSH so on in a UNIX/Linux based systems.

It has a friendly web interface and very useful tool for system administrators.


Steps to install Monit

$ sudo apt-get install monit

Configure Monit by

$ sudo vi /etc/monit/monitrc

Polling frequency (This is the interval (in seconds) at which Monit runs its tests.)

set daemon 120

Edit (Uncomment following)

set httpd port 2812 and
use address localhost # only accept connection from localhost
allow localhost # allow localhost to connect to the server
allow admin:monit # require user 'admin' with password 'monit'
allow @monit # allow users group 'monit' to connect (rw)
allow @users readonly # allow users group 'users' to connect (r)

Add monitoring service for Nginx

check process nginx with pidfile /var/run/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"

Check for syntax errors

$ sudo monit -t

When there are no errors and shows message like “Control file syntax OK“ then


Restart Monit

$ sudo /etc/init.d/monit restart

Verify Monit running by checking the logs

$ sudo tail -f /var/log/monit.log
Build to explore

Written by

Vipala is a developer. Passionate about her work. She doesn’t restrict herself to a certain role. In her free time, Vipala hand-crafts for her daughter Gargee.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade