How To Install and Configure Monit for Nginx and PHP-FPM
About Monit
Monit is a helpful program that automatically monitors and manages server programs to ensure that they not only stay online consistently, but that the file size, checksum, or permissions are always correct. Additionally monit comes with a basic web interface through which all of the processes can be set up. This tutorial will cover the most basic setup and configuration.
Install Monit
Monit is easiest to install through apt-get:
sudo apt-get install monit
Once monit downloads, you can add programs and processes to the configuration file:
sudo nano /etc/monit/monitrc
Monit can be started up with a command that then keeps it running in the background
monit
Typing monit status
displays monit’s details
Configure Monit for NGINX and PHP-FPM
# NGINX
check process nginx with pidfile /var/run/nginx.pid
group webserver
start program = “/usr/sbin/service nginx start”
stop program = “/usr/sbin/service nginx stop”
if failed host localhost port 80 protocol http
and request “/humans.txt”
then restart# PHP5-FPM
check process php5-fpm with pidfile /var/run/php5-fpm.pid
group webserver
start program = “/usr/sbin/service php5-fpm start”
stop program = “/usr/sbin/service php5-fpm stop”
if failed host localhost port 80 protocol http
and request ‘/ping’
then restart
depends on nginx
Once this is configured, monit should reload and reread the configuration file, and the web interface will be available:
monit reload Hire Freelancer to configure your server.