Enable server-status page to monitor Apache web server load

Mod-status is an Apache module which allows server administrators to monitor how well their server is performing with an HTML interface which can be accessible via web browser.

For this tutorial you must have a knowledge on how to install and configure Basic Apache Server.

Apache status

 How to Enable mod_status in Apache

By default Apache comes with mod_status enabled, If not we can do it in Apache configuration file:

nano /etc/httpd/conf/httpd.conf

Open the file and Search for the word “mod_status” or keep scrolling down until you find a line containing:

#LoadModule status_module modules/mod_status.so

#means mod_status is disabled. Remove the ‘#‘ from start of line to enable mod_status.

LoadModule status_module modules/mod_status.so

How to configure mod-status

Now search for the word “Location” or scroll down until you find a section for mod_status which would look like following:

# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Change the ".example.com" to match your domain to enable.
#<Location /server-status>
# SetHandler server-status
# Order deny,allow
# Deny from all
# Allow from .example.com
#</Location>

In the above, uncomment the lines for Location directiveSetHandler and the directory restrictions as per your requirements. For example, we can keep it simple with the Order Allowdeny and it’s allowed for all.

<Location /server-status>
SetHandler server-status
Order allow,deny
Deny from all
Allow from all
</Location>

If you have created more than one Apache virtual hosts, you need to define the same configuration for each virtual host for any domains you’ve configured in Apache.

For Example it will look like this:

<VirtualHost *:80>

ServerAdmin tecmint@example.com
DocumentRoot /var/www/html/example.com
ServerName example.com
ErrorLog logs/example.com-error_log
CustomLog logs/example.com-access_log common
<Location /server-status>
SetHandler server-status
Order allow,deny
Deny from all
Allow from example.com
</Location>
</VirtualHost>

Enable ExtendedStatus:

By enabling “ExtendedStatus” we will be able to get the more statistical information like, CPU usagerequest per secondtotal traffic, etc. To enable it, we have to edit the same httpd.conf file and search for the word “Extended” and Uncomment the line and need to set the status “On” for ExtendedStatus directive.

# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
ExtendedStatus On

Restart Apache:

Now to make sure that you’ve correctly enabled and configured Apache server status page run:

# httpd -t
Syntax OK

Finally restart the httpd service:

Service httpd restart

Access mod_status Page:

Now the Apache status page will be accessible via your domain name with “/server-status” at the following URL’s.

http://serveripaddress/server-status
OR
http://serev-hostname/server-status

Now with the above HTML you can see all information about server uptime, process Id with its respective client, and the page they are trying to access.It will helps us to understand the situation better.

You can refresh the page every time to see the updated statistics.

You can also set the automatic refresh to do that, You can add “?refresh=N” at the end of the URL. Where N can be replaced with the number of seconds which you want your page to get refreshed.

http://serveripaddress/server-status/?refresh=5

To view the Apache status page from the command-line interface using the special command-line browsers called links or lynx. You can install them using below command:

# yum install links
OR
# yum install lynx

Once done, you can get the same statistics on your terminal by using following command.

links http://serveripaddress/server-status
OR
lynx http://serveripaddress/server-status
OR
/etc/init.d/httpd fullstatus

That’s all for now, we will come with more tips and tricks on cpanel and plesk in future tutorials. Till then stay tuned to cpanelplesk.com and don’t forget to send your valuable comments.