Monit is a handy program that monitors and manages server programs to make sure that are running and start them if they are not.
To install and configure monit you will need to ssh into your server, once in check to make sure the monit package is available
aptitude search monitin the list you should see monit with a description
p   monit       - utility for monitoring and managing daemons or similar programsNext to install monit run
aptitude install monityou can then check and modify the config
vi /etc/monit/monitrcTo add custom monitors add a config file to /etc/monit/conf.d/
as an example that will stat apache if it stops edit or create /etc/monit/conf.d/apache and add a basic config
check process apache with pidfile /run/apache2.pid
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program  = "/etc/init.d/apache2 stop"mysql example
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"After you have created your config files check that there are no syntax error
/etc/init.d/monit syntax or
monit -tthen reload or restart the monit service
/etc/init.d/monit reloadJob done