Apache is the world’s most widely used, cross-platform HTTP web server that is frequently deployed on Linux and Unix systems for hosting websites or web applications. Importantly, it's simple to install and comes with a straightforward configuration.
[ You might also like: How to Hide Apache Version Number and Other Sensitive Info ]In this guide, we will walk you through how to check the uptime of an Apache web server on a Linux system using several methods as explained below.
1. Systemctl Command
The systemctl command serves as a utility for managing the systemd system and service manager; it's commonly used to start, restart, stop services, and more.
The systemctl status sub-command is used to display the current state of a service. You can use it to verify whether your Apache web server is running.
<code>$ sudo systemctl status apache2 #Debian/Ubuntu # systemctl status httpd #RHEL/CentOS/Fedora </code>
[ You might also like: Useful Commands to Manage Apache Web Server in Linux ]### 2. Apachectl Command
The apachectl utility is designed to manage and control the Apache web server. It's typically used for starting, stopping, restarting, and performing other administrative tasks related to Apache.
<code>$ sudo apachectl start [Start Apache web server] $ sudo apachectl stop [Stop Apache web server] $ sudo apachectl restart [Restart Apache web server] $ sudo apachectl graceful [Graceful Restart of Apache web server] $ sudo apachectl configtest [Check Apache Configuration] $ sudo apachectl -V [Check Apache Version] $ sudo apachectl status [Check Apache Status]</code>
The apachectl tool can also be used to enable or disable Apache modules. One such module is mod_status, which provides a web-based interface showing real-time information about the Apache server's performance and status.
Enable Apache Server Status in Debian/Ubuntu
By default, the Apache server-status feature is enabled within the /etc/apache2/mods-enabled/status.conf configuration file.
<code>$ sudo vi /etc/apache2/mods-enabled/status.conf</code>
Within the <location></location>
block, include the following lines to permit access from specific IPs or your local network.
You may also use Require all granted to allow unrestricted access, but keep in mind the potential security risks.
After making changes, save the file and restart Apache to apply them:
<code>$ sudo service apache2 restart</code>
Enable Apache Server Status in RHEL Systems
To activate the server-status functionality in RHEL-based systems, create a new file as follows:
<code># vi /etc/httpd/conf.d/server-status.conf</code>
Add the following content into the file:
<code><location> SetHandler server-status Require ip your_ip_address_or_network </location></code>
Save and exit the file, then restart the web service:
<code># systemctl restart httpd</code>
If you're working from the terminal, you may need a text-based browser like lynx or links:
<code>$ sudo apt install lynx #Debian/Ubuntu # yum install links #RHEL/CentOS</code>
Then run the following to view Apache uptime:
<code>$ apachectl status</code>
Alternatively, open the following URL in a graphical browser to view detailed server status:
<code>http://localhost/server-status OR http:SERVER_IP/server-status</code>
3. ps Command
The ps command is used to display information about currently running processes on a Linux system. Combined with grep, it can be used to determine the uptime of the Apache service.
Flags explanation:
-
-e
– selects all active processes. -
-o
– defines custom output fields (comm – command name, etime – elapsed time, user – process owner).
<code># 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</code>
The output below shows the apache2 process has been active for 4 hours, 10 minutes, and 28 seconds (pay attention only to the instance started by root).
Additional recommended reading:
You might also like:
- 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
This article has covered three effective methods for checking the uptime of the Apache/HTTPD service on Linux systems. If you have any questions or suggestions, feel free to share them in the comments section below.
The above is the detailed content of 3 Ways to Check Apache Server Status and Uptime in Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

While writing program files or normal text files, programmers and writers sometimes want to know the difference between two files or two versions of the same file. When you compare two computer files on Linux, the difference between their contents is

There are three ways to create empty files in the command line: First, the simplest and safest use of the touch command, which is suitable for debugging scripts or placeholder files; Second, it is quickly created through > redirection but will clear existing content, which is suitable for initializing log files; Third, use echo"> file name to create a file with an empty string, or use echo-n""> file name to avoid line breaks. These three methods have their own applicable scenarios, and choosing the right method can help you complete the task more efficiently.

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

Eclipse is a free integrated development environment (IDE) that programmers around the world use to write software, primarily in Java, but also in other major programming languages using Eclipse plugins.The latest release of Eclipse IDE 2023?06 does

dutree is a free, open-source, fast command-line tool for analyzing disk usage, written in the Rust programming language. It was created by combining durep (disk usage reporter) and tree (list directory content in tree-like format) command-line tools

ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage, and query network interface parameters via command-line interface or in a system configuration scripts

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

Linux has a rich collection of commands, and while many of them are powerful and useful for various tasks, there are also some funny and whimsical commands that you can try out for amusement. 1. sl Command (Steam Locomotive) You might be aware of the
