Archive

Posts Tagged ‘apache status’

How to Check if Apache Is Up and Restart if Not

September 17th, 2008 No comments

I do often monitor status as most often reason of is Apache overload. Some web hosting panels are sending notifications when your server is down; some web services like Alertra.com provide you with different and one of my hosters has his internal . But what to do if you need to go anywhere where you can’t get access to your server? You’ll need a cron task that will check whether apache is up and will restart it if not.

I’ve found a solution at a forum. You’ll need a simple shell script and here it is:

#!/bin/sh
run=`ps ax | grep /usr/sbin/httpd | grep -v grep | cut -c1-5 | paste -s -`
if [ "$run" ];
then
echo “Apache is running”
else
/etc/init.d/httpd start
fi

This script will check for a number of running script processes and will try to start apache if it is not running. You should add this script to crontab with any frequency you like. I’d suggest to run it every 3 minutes as it doesn’t cause , but your apache stability is vital.

Categories: Apache Performance, Linux Tricks Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Viewing Apache Server Status From Your Browser

April 29th, 2008 No comments

Sometimes you need to have a look at , especially, if your server serves many users and if often busy. You should monitor you server’s CPU load, and view other information.

There is a simple solution in httpd.conf, that allows you to do this directly from your browser. All you need is just to add some lines to your configuration file. First of all, you should have the following sting, that makes this possible:
LoadModule status_module modules/mod_status.so

Usually at the bottom of the httpd.conf you can find some lines about server status. Let’s take the comments off.
ExtendedStatus On

This will show you more information, it’s what you exactly need. You don’t have to make this information public, but it will be very informative and useful for you. Then go down and add these lines:
<Location /server-status>
SetHandler server-status
</Location>

This URL will be relative to your Servername, so make sure you have set it up. You also should protect this location  just as shown in the sample httpd.conf:

#    Order deny,allow
#    Deny from all
#    Allow from .example.com

Just add your own limits and have fun! is done!