habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Apache Enable Mod Status

3 min read

apache-enable-mod-status

Hi Dude, Today is happy day, hahha. Ok just do it. This article about apache enable mod status. Enabling the Apache mod_status module allows us to monitor the performance and status of Apache web server. The mod_status module provides a web-based interface that displays real-time information about the server, including details about current requests, server uptime, and more.

Before jump to installation, I will simply explain what is mod status in apache and the function of mod status itself. Mod_status is an Apache module that helps to monitor web server load and current httpd connections that accessed via browser.

As a description, main function is monitor web server load. The details given are:

  • The number of workers serving requests
  • The number of idle workers
  • The status of each worker, the number of requests that worker has performed and the total number of bytes served by the worker (*)
  • A total number of accesses and byte count served (*)
  • The time the server was started/restarted and the time it has been running for
  • Averages giving the number of requests per second, the number of bytes served per second and the average number of bytes per request (*)
  • The current percentage CPU used by each worker and in total by all workers combined (*)
  • The current hosts and requests being processed (*)

The lines marked “(*)” are only available if ExtendedStatus is On. In version 2.3.6, loading mod_status will toggle ExtendedStatus On by default.

See also  Apache Increase Request Timeout

Install Apache Web Server.

Mod Status Apache built with apache web server package. If we dont have Apache web server, lets install first.

root@habibza:~# apt install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0 ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0 ssl-cert
0 upgraded, 11 newly installed, 0 to remove and 5 not upgraded.
Need to get 1,866 kB of archives.
After this operation, 8,091 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y

After finished install apache, check status is running or not.

root@habibza:~# service apache2 status
 apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-11-12 17:04:34 WIB; 3min 57s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 15306 (apache2)
      Tasks: 55 (limit: 2245)
     Memory: 5.9M
     CGroup: /system.slice/apache2.service
             ├─15306 /usr/sbin/apache2 -k start
             ├─15308 /usr/sbin/apache2 -k start
             └─15309 /usr/sbin/apache2 -k start

Ok, Apache is running well. Active and running. Lets open browser with ip address or url.

http://ip-server-apache-web
apache enable mod status
Apache default page

Lets check version apache installed. Use command apache2ctl -V.

root@habibza:~# apache2ctl -V
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2021-10-14T16:24:43
Server's Module Magic Number: 20120211:88
Server loaded:  APR 1.6.5, APR-UTIL 1.6.1
Compiled using: APR 1.6.5, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"

From the output of the command is "Apache/2.4.41 (Ubuntu)", we can easy know that apache version is 2.4.41 and running on ubuntu machine. Important point is that server running MPM event. I will write article separately about MPM.

See also  Easy Install and Configure Certbot Lets Encrypt Apache on Centos 7

Check Module Mod Status

After install apache and make sure status running well, how to view the server-status? Let’s first check whether the Mod Status has been installed or not.

root@habibza:~# apache2ctl -M | grep status
 status_module (shared)

Result output show to us that mod status module already installed.

By default mod status is bundling with apache installation. If the mod status is not active, run the command a2enmod status like below to enable.

root@habibza:/home# a2enmod status
Enabling module status.
To activate the new configuration, you need to run:
  systemctl restart apache2
root@habibza:/home# systemctl restart apache2
root@habibza:/home# apache2ctl -M | grep status
 status_module (shared)

View Server Status

After apache run and mod status had enable. Next, open apache.conf directory then add some parameter.

root@habibza:/home# vim /etc/apache2/mods-enabled/status.conf

Edit the line add code below.

 <Location /server-status>
                SetHandler server-status
                Require ip 192.168.197.0/24
 </Location>
  • Require ip 192.168.197.0/24 : Allow access only from 192.168.197.0/24

Next, lets restart service apache.

root@habibza:/home# service apache2 restart

After restart service, continue open browser and type below.

http://ip-server-web-apache/server-status
apache enable mod status

Yeay, apache enable mod status had installed successfull and works. Be cautious about exposing the server status page to the public internet, as it can potentially provide sensitive information about server. Always restrict access to trusted IP addresses.

May be it’s helpful, please feel free to leave a comment if you have any questions and I’ll appreciate it.


Let's Buy Me Coffee.

Buy Me a Coffee at ko-fi.com

https://saweria.co/habibzain
https://ko-fi.com/habibzain
habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Ansible Ubuntu 20.04

Introduction Ansible is an open-source automation tool that simplifies configuration management, application deployment, and task automation. It is designed to be simple, lightweight, and...
habibzain
1 min read

Leave a Reply

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

Never miss good article from us, get weekly updates in your inbox