Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Configure Apache Monitoring With Zabbix

Steps

Enable Status Module

Ensure that the status module is enabled

sudo a2enmod status

Site Configuration

We need to configure Apache to respond with status on the /server-status path, but only when connected to from localhost, rather than our normal website(s).

Thus use the following command to create a site configuration:

sudo editor /etc/apache2/sites-available/localhost.conf

Fill it with the following content:

<VirtualHost 127.0.0.1:80>

    ServerName localhost
    ServerAdmin webmaster@localhost

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

    ErrorLog ${APACHE_LOG_DIR}/localhost-status-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/localhost-status-access.log combined

</VirtualHost>

After having done that, enable the site by running:

sudo a2ensite localhost

Config Test

Perform a configuration test to check Apache is okay with everything:

 sudo apache2ctl configtest

Restart Apache Service

Run the following command to restart Apache and start using the new config. It shouldn't interfere with your other configs, because it is specific to 127.0.0.1 and requires the connection to be coming from 127.0.0.1.

sudo systemctl reload apache2

Test

Run the following command from the shell on the server to check you can get the status:

wget http://127.0.0.1/server-status

This should result in the creation of a file called server-status with content similar to below (just the first few lines):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head>
<title>Apache Status</title>
</head><body>
<h1>Apache Server Status for 127.0.0.1 (via 127.0.0.1)</h1>

<dl><dt>Server Version: Apache/2.4.57 (Debian)</dt>

Configure Zabbix Server

We have finished setting up the host, now we need to configure our Zabbix server to try and pull this information using the agent. Simply click on the Host and go to the templates and add Apache by Zabbix agent.

That's it!

References

Last updated: 5th June 2024
First published: 13th July 2023

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch