Apache is an open-source, cross-platform HTTP web server that is widely used to run web applications or websites. Apache is prevalent for its affordability and anyone can download and use it without any complex licensing issues. This massive popularity is fueled by a large user base who use Apache as their default web server software.
Apache is also extremely easy to use and the configuration process takes less effort than many of its competitors. You can learn the full setup process for the installation and configuration of Apache on Linux by clicking on our useful Apache command tips article.
In this article, we focus on the apache status command and how to effectively use it to understand and check Apache web server uptime on a Linux system. This is valuable information for any web developer who wants to get started with Apache.
The Apache HTTP server’s control interface is called apachectl. This method needs the mod_status module installed and activated, which allows it to show information on the server’s performance, including system uptime (which is the default setting).
Using the file /etc/apache2/mods-enabled/status.conf the server-status component is enabled by default.
To enable server-status components in RHEL/CentOS follow the steps below.
Step 1: Create a file using vi: /etc/httpd/conf.d/server-status.conf
Step 2: Add the following configuration
#Require host localhost
Step 3: Save the file and restart Apache web server. You can use the following command for a quick restart.
Step 4: Next install a command line web browser (lynx or links) if you do not have it already.
# yum install links #RHEL/CentOS
Step 5: And finally, run the following command to check the Apache service uptime
Alternatively, you can use the following command to view the Apache web server status information from a graphical web browser.
Using the ps command, you can find a selection of the active processes running on a Linux system. You can use the following grep command to check Apache service uptime.
Note: Here are some useful grep commands that will come in handy.
-o – is used to specify output.
# ps -eo comm,etime,user | grep apache2
# ps -eo comm,etime,user | grep root | grep apache2
The sample output below shows that apache2 service has been running for 9 minutes and 1 seconds. This is how long the apache server is online.
Systemctl is by far the most versatile command that allows users to control systemd system and service manager. You can also use it to start, restart, and stop services using the terminal.
In this article, we showed you three different ways to check Apache/HTTPD service uptime on a Linux system. Using the command anyone even with no prior knowledge in working with Apache services can get valuable insight into service uptime.