3 Ways to Check Apache Server Status and Uptime in Linux

Apache is a popular open-source web server that powers a large percentage of websites on the internet. In Linux, Apache can be easily installed and configured to serve web pages and other content. However, it's important to monitor the status and uptime of your Apache server to ensure it's running smoothly and efficiently. In this article, we'll explore three different ways to check Apache server status and uptime in Linux.

Method 1: Using systemctl Command

systemctl is a powerful command-line tool used to manage systemd services in Linux. It provides detailed information about service status, including Apache web server.

Steps to Check Apache Status

Step 1: Open a terminal window on your Linux system.

Step 2: Run the following command to check the status of Apache service:

sudo systemctl status apache2

Step 3: If Apache server is running, you'll see output similar to this:

? apache2.service - Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2023-03-13 10:25:21 EDT; 2 days ago
   Main PID: 1234 (apache2)
      Tasks: 55 (limit: 9378)
     Memory: 164.9M
        CPU: 1min 10.986s
     CGroup: /system.slice/apache2.service
             ??1234 /usr/sbin/apache2 -k start
             ??1235 /usr/sbin/apache2 -k start
             ??1236 /usr/sbin/apache2 -k start

Step 4: If Apache server is not running, you'll see output like this:

? apache2.service - Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2023-03-13 10:25:21 EDT; 2 days ago
   Process: 1234 ExecStart=/usr/sbin/apache2 -k start (code=exited, status=0/SUCCESS)
   Main PID: 1234 (code=exited, status=0/SUCCESS)

The Active status indicates whether Apache server is running or not. When running, you'll also see the start time, memory usage, CPU usage, and process information.

Method 2: Using apachectl Command

The apachectl command is Apache's built-in control interface that comes with the Apache web server package. It provides server-specific status information.

Steps to Check Apache Status with apachectl

Step 1: Open a terminal window on your Linux system.

Step 2: Run the following command:

sudo apachectl status

Step 3: If Apache server is running, you'll see detailed server information:

Apache Server Status for localhost (via 127.0.0.1)

   Server Version: Apache/2.4.46 (Ubuntu)
   Server MPM: event
   Server Built: 2021-08-17T18:02:37
   Server loaded APR Version: 1.7.0
   Compiled with APR Version: 1.7.0
   Server loaded APU Version: 1.6.1
   Compiled with APU Version: 1.6.1

Step 4: If Apache is not running, you'll receive an error message indicating the server is not accessible.

This method displays comprehensive server information including version details, server MPM (Multi-Processing Module), and build information.

Method 3: Using mod_status Module

Apache's mod_status module provides real-time server status information through a web interface. This method offers the most detailed uptime and performance metrics.

Steps to Enable and Use mod_status

Step 1: Enable the mod_status module:

sudo a2enmod status

Step 2: Edit the status configuration file:

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

Step 3: Add the following configuration to enable local access:

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

Step 4: Restart Apache to apply changes:

sudo systemctl restart apache2

Step 5: Access the server status page in your web browser:

http://localhost/server-status

Step 6: You'll see comprehensive server status information:

Apache Server Status for localhost

Server Version: Apache/2.4.46 (Ubuntu)
Server MPM: event
Server Built: 2021-08-17T18:02:37
Current Time: Wednesday, 15-Mar-2023 11:27:38 EDT
Restart Time: Monday, 13-Mar-2023 10:25:21 EDT
Parent Server Config. Generation: 1
Parent Server MPM Generation: 0
Server uptime: 2 days 1 hour 2 minutes 17 seconds
Server load: 0.15 0.18 0.12
Total accesses: 3462 - Total Traffic: 54.6 MB
CPU Usage: u16.55 s14.10 cu0.00 cs0.00 - .0072% CPU load
1.4 requests/sec - 23.0 kB/second - 16.1 kB/request
1 requests currently being processed, 7 idle workers

The mod_status page displays crucial metrics including server uptime, total requests served, traffic volume, CPU usage, and current server load.

Comparison of Methods

Method Information Type Access Level Best For
systemctl Service status, basic uptime Command line Quick status checks
apachectl Server configuration details Command line Configuration verification
mod_status Real-time metrics, detailed uptime Web interface Performance monitoring

Additional Monitoring Tips

  • Use journalctl -u apache2 to view detailed Apache service logs and troubleshoot issues.

  • Consider implementing monitoring tools like Nagios, Zabbix, or Prometheus for automated Apache monitoring and alerting.

  • Keep Apache updated with security patches using sudo apt update && sudo apt upgrade on Debian-based systems.

  • For production environments, enable extended status in mod_status by adding ExtendedStatus On to your Apache configuration.

Conclusion

Monitoring Apache server status and uptime is essential for maintaining a reliable web service. The three methods covered?systemctl for quick status checks, apachectl for server details, and mod_status for comprehensive real-time monitoring?provide different levels of information to suit various administrative needs. Regular monitoring helps ensure optimal server performance and quick issue resolution.

Updated on: 2026-03-17T09:01:38+05:30

15K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements