Monitor Apache Web Server Using Mod_status

Spread the love

Apache is the most well-known and widely used web server around the world. For a Linux system administrator, it is important to monitor and debug Apache performance problems. Mod_status is an Apache module that displays a web page containing statistics about the web server’s current state including worker processes and active connections. It helps to monitor web server load with an HTML interface via a web browser. It is one of the most helpful and easiest modules to configure when you install Apache on Ubuntu.

Apache’s mod_status module shows you the following information:

  • Restart Time
  • Server Uptime
  • Server Load
  • CPU Usage and CPU Load
  • Total incoming requests
  • Total number of bytes and counts server
  • Total number of idle and busy workers

You can see a demo of Apache’s status by visiting the following URL: https://status.apache.org/

Enable mod_status in Apache

By default, mod_status module is enabled in Ubuntu 14.04. If not, you can enable it by running:

sudo a2enmod status

Configure mod_status

To enable access to the server status page, you need to edit the mod_status default configuration file located in the “/etc/apache2/mods-enabled/” directory. You can edit the “status.conf” file by running:

sudo nano /etc/apache2/mods-enabled/status.conf

Find the section Location /server-status, remove the # before the 192.0.2.0/24 line and add the IP address of the remote computer you will be using to access your web server:

<Location /server-status>
                SetHandler server-status
                Require local
                Require ip 192.168.1.20
</Location>

Save and close the file.

The above configuration is only for the default Apache website. If you have created one or more websites (Virtual Hosts), then the above configuration won’t work. You will need to configure the above settings for each virtual host. In this example let’s configure the Apache default virtual host for mod_status.

You can do this by editing the Apache default virtual host config file:

sudo nano /etc/apache2/sites-enabled/000-default.conf

Add the following lines under the section VirtualHost *:80:

<Location /server-status>
                SetHandler server-status
                Require local
                Require ip 192.168.1.20
</Location>

Save and close the file and restart Apache to reflect the changes.

sudo /etc/init.d/apache2 restart

View the Status Page

Now, from a remote machine, open your web browser and access the Apache status page using url “http://your-server-ip/server-status“.

You will see something like the above page that will give you information of your Apache server’s performance and load.

Conclusion

Apache’s mod_status module is a very useful tool for monitoring a web server’s performance. Monitoring the Apache statistics will help you to configure Apache to achieve the best performance.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Hitesh Jethva

Over 5 years of experience as IT system administrator for IT company in India. My skills include a deep knowledge of Rehat/Centos, Ubuntu nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, squied proxy, NFS, FTP, DNS, Samba, ldap, Openvpn, Haproxy, Amazon web services, WHMCS, Openstack Cloud, Postfix Mail Server, Security etc.

Comments (1)