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 monit
in the list you should see monit with a description
p monit - utility for monitoring and managing daemons or similar programs
Next to install monit run
aptitude install monit
you can then check and modify the config
To 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"
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 -t
then reload or restart the monit service