Apache | Apache Server Management (mod_status) | Checking Runtime Status (server-status)

Apache provides a handler called server-status in the mod_status module. A handler is like a function that performs a certain action; you can think of it as a group of program logic.

By calling the server-status handler, you can check Apache’s runtime status. Let’s configure it so the runtime status can be viewed by calling the server-status handler from a browser.

Load the mod_status Module

First, load the module with LoadModule so the mod_status module can be used. Search for mod_status in the httpd.conf file, and you should find the following.

#LoadModule status_module modules/mod_status.so

If there is a # before LoadModule, remove it.

LoadModule status_module modules/mod_status.so

Next, configure the server-status handler call. Use Include to load the httpd-info.conf file. Search for httpd-info.conf in the httpd.conf file, and you should find the following.

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

If there is a # before Include, remove it.

# Real-time info on requests and configuration
Include conf/extra/httpd-info.conf

Check the httpd-info.conf File

Next, search for /server-status in the httpd-info.conf file, and you should find the following.

<Location /server-status>
    SetHandler server-status
    Require host .example.com
    Require ip 127
</Location>

Location sets the URL path to /server-status, and SetHandler specifies that the server-status handler should be called and executed when the URL path /server-status is requested.

With this configuration, when the browser requests http://localhost/server-status, the server-status handler runs and returns the result. The server runtime status should not be exposed to everyone, so access is allowed only from localhost.

Check Execution

Access http://127.0.0.1/server-status locally.

server-status

If you can access the URL like this, you can monitor Apache’s runtime status as shown above.

Automatic Updates at a Specified Interval

When connecting from localhost, add ?refresh=seconds as a URL parameter to fetch the latest information again at the specified interval.

For example, enter http://127.0.0.1/server-status?refresh=5 to update automatically every 5 seconds.

server-status

As shown above, you can confirm that the latest information is fetched again and displayed automatically every 5 seconds.