how to auto restart apache when it goes down

Jump to: navigation, search

Create a shell script with following

# Apache Process Monitor
checkapache=`ps ax | grep -v grep | grep -c httpd`
if [ $checkapache -le 0 ]
/usr/local/apache/bin/apachectl startssl

Save it as /root/utils/

Then set cronjob

*/5 * * * * sh /root/utils/ >/dev/null 2>&1

This will check Apache every 5 minutes, and if no httpd processes are running it will automatically restart the daemon.