Ivan Tomica

Enable mod_status in Apache 2.4

Thing that I miss with Apache on CentOS 7, and in the matter of fact, every SystemD based distribution is running service httpd status and immediately seeing full Apache status along with number of active connections, server uptime etc.

This article will focus on how to enable mod_status in Apache 2.4 so you can successfully utilize apachectl fullstatus command from your server to display web server statistics.

Prerequisites for apachectl fullstatus option to work are mod_status module installed and enabled in Apache configuration and links or some other text based web browser. To install links on CentOS 7 you can use:

yum -y install links

To check if mod_status is enabled on your Apache install you can use one of the following methods:

# httpd -M | grep status
 status_module (shared)

or

# grep mod_status /etc/httpd/conf.modules.d/*
/etc/httpd/conf.modules.d/00-base.conf:LoadModule status_module modules/mod_status.so

Second step is to enable server status location. While checking server status apachectl command tries to fetch /server-status contents. By default this will probably result in 404 or 403 error depending on your Apache (virtual hosts) configuration. To enable /server-status location you need to create additional configuration directive in /etc/httpd/conf.d , lets call it:

/etc/httpd/conf.d/server-status.conf

edit that file in your favorite text editor (hence vi) and place following code in it:

<IfModule mod_status.c>
    <Location "/server-status">
        SetHandler server-status
        Require host YOURHOSTNAME
    </Location>
</IfModule><

IfModule directive ensures that your server starts even if mod_status is not loaded which will hopefully prevent your web server from not working at all if module is not loaded. In above mentioned example you’ll need to replace YOURHOSTNAME with, well, your host name to limit access to server status page so only you can see it from server itself as it may hold some information that you may not want to share with others.

Next step is to restart your web server:

systemctl restart httpd.service

and after that enjoy yourself:

apachectl fullstatus
Tagged in:, ,
About 
Sysadmin on the everlasting journey of learning. Always in search for an opportunity to prove myself and to learn something new. My addiction is learning and my main goal is to excel in every aspect of Linux/Unix system administration.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *