3 Methods to Check Apache Server Status and Uptime in Linux

Apache is the world’s most popular, cross-platform HTTP web server that is commonly used in Linux and Unix platforms to deploy and run web applications or websites. Importantly, it’s easy to install and has a simple configuration as well.

In this article, we will show how to check Apache web server uptime on a Linux system using different methods/commands explained below.

1. Systemctl Command

systemctl command is a utility for controlling the systemd system and service manager; it is used it to start, restart, and stop services, and beyond.

The systemctl status sub-command, as the name states are used to view the status of a service, you can use it to check the running status of your Apache web server.

$ sudo systemctl status apache2	  #Debian/Ubuntu 
# systemctl status httpd	  #RHEL/CentOS/Fedora 
Check Apache Status Using Systemctl
Check Apache Status Using Systemctl

2. Apachectl Command

The apachectl command is used to control and manage the Apache, which is primarily used for starting, stopping, and restarting the Apache web server, as well as performing other administrative tasks.

$ sudo apachectl start       [Start Apache web server]
$ sudo apachectl stop        [Stop Apache web server]
$ sudo apachectl restart     [Restart Apache web server]
$ sudo apachectl graceful    [Gracefully Restart Apache web server]
$ sudo apachectl configtest  [Check Apache Configuration]
$ sudo apachectl -V          [Check Apache Version]
$ sudo apachectl status      [Check Apache Status]

The apachectl command can be used to enable or disable Apache modules, including the mod_status module, which provides an interface that displays information about the Apache web server’s current status and performance.

Enable Apache Server Status in Debian/Ubuntu

The Apache server-status component is enabled by default in the file /etc/apache2/mods-enabled/status.conf configuration file.

$ sudo vi /etc/apache2/mods-enabled/status.conf

Inside the <Location /server-status> section, add the following lines to allow access from your IP address or network.

Apache Mod_Status Configuration
Apache Mod_Status Configuration

You can also use Require all granted to allow access from all IPs but be cautious about security implications.

Save the configuration file and restart the Apache service to apply the changes:

$ sudo service apache2 restart

Enable Apache Server Status in RHEL Systems

To enable the Apache server-status component in RHEL-based distributions, create a file below.

# vi /etc/httpd/conf.d/server-status.conf

and add the following configuration.

<Location "/server-status">
    SetHandler server-status
    Require ip your_ip_address_or_network
</Location>

Save the file and close it. Then restart the web server.

# systemctl restart httpd

If you are primarily using a terminal, then you also need a command-line web browser such as lynx or links.

$ sudo apt install lynx		#Debian/Ubuntu
# yum install links		#RHEL/CentOS

Then run the command below to check the Apache service uptime:

$ apachectl status
Check Apache Status Using Apache2ctl
Check Apache Status Using Apache2ctl

Alternatively, use the URL below to view the Apache web server status information from a graphical web browser:

http://localhost/server-status
OR
http:SERVER_IP/server-status

3. ps Command

ps command is used to show information concerning a selection of the active processes running on a Linux system, you can use it with the grep command to check Apache service uptime as follows.

Here, is the flag:

  • -e – enables selection of every process on the system.
  • -o – is used to specify output (comm – command, etime – process execution time, and user – process owner).
# ps -eo comm,etime,user | grep apache2
# ps -eo comm,etime,user | grep root | grep apache2
OR
# ps -eo comm,etime,user | grep httpd
# ps -eo comm,etime,user | grep root | grep httpd

The sample output below shows that the apache2 service has been running for 4 hours, 10 minutes, and 28 seconds (only consider the one started by root).

Check Apache Uptime
Check Apache Uptime

Lastly, check out more useful Apache web server guides:

In this article, we showed you three different ways to check Apache/HTTPD service uptime on a Linux system. If you have any questions or thoughts to share, do that via the comment section below.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

4 Comments

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.