Apache is a 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.
Read Also: How to Hide Apache Version Number and Other Sensitive Info
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 Utility
Systemctl is a utility for controlling the systemd system and service manager; it is used it to start, restart, stop services and beyond. The systemctl status sub-command, as the name states is used to view the status of a service, you can use it for the above purpose like so:
$ sudo systemctl status apache2 #Debian/Ubuntu # systemctl status httpd #RHEL/CentOS/Fedora
2. Apachectl Utilities
Apachectl is a control interface for Apache HTTP server. This method requires the mod_status (which displays info about the server is performing including its uptime) module installed and enabled (which is the default setting).
The server-status component is enabled by default using the file /etc/apache2/mods-enabled/status.conf.
$ sudo vi /etc/apache2/mods-enabled/status.conf
To enable server-status component, create a file below.
# vi /etc/httpd/conf.d/server-status.conf
and add the following configuration.
<Location "/server-status"> SetHandler server-status #Require host localhost #uncomment to only allow requests from localhost </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
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 Utility
ps is a utility which shows information concerning a selection of the active processes running on a Linux system, you can use it with grep command to check Apache service uptime as follows.
Here, the flag:
-e– enables selection of every processes 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 apache2 service has been running for 4 hours, 10 minutes and 28 seconds (only consider the one started by root).
Lastly, check out more useful Apache web server guides:
- 13 Apache Web Server Security and Hardening Tips
- How to Check Which Apache Modules are Enabled/Loaded in Linux
- 5 Tips to Boost the Performance of Your Apache Web Server
- How to Password Protect Web Directories in Apache Using .htaccess File
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.