Check Apache Server Status and Uptime in Linux

Apache is the go-to web server for many, thanks to its widespread use across Linux and Unix platforms for deploying websites and applications. Its installation and setup are straightforward, making it a favorite among many.

But even champions need check-ups! Fortunately, checking your Apache server’s status and uptime in Linux is a breeze. Here are three methods to get you started:

Using the systemctl Command

First up is the systemctl command. This tool is part of the systemd system and service manager toolkit, which is pretty handy for starting, stopping, and managing services, including Apache.

To check if your Apache server is up and running, you’d use the systemctl status command like so:

For Debian/Ubuntu:

sudo systemctl status apache2

For RHEL/CentOS/Fedora:

systemctl status httpd

This command gives you a snapshot of the Apache service’s current status.

Tapping into the apachectl Command

Next, we have the apachectl command, a Swiss army knife for Apache server management. It allows you to start, stop, and restart the service, as well as check its status.

Here are a few examples:

  • Start the Apache web server: sudo apachectl start
  • Stop the server: sudo apachectl stop
  • Restart the server: sudo apachectl restart
  • Perform a graceful restart: sudo apachectl graceful
  • Check the Apache configuration: sudo apachectl configtest
  • Get the Apache version: sudo apachectl -V
  • Check the Apache server’s status: sudo apachectl status

The apachectl command is also your go-to for enabling or disabling Apache modules, including the mod_status module. This module offers a web interface showing the server’s current status and performance metrics.

The ps Command Route

Lastly, the ps command lets you peek at active processes on your system, including Apache. By combining it with the grep command, you can filter out Apache’s process and check its uptime.

For Apache2:

ps -eo comm,etime,user | grep apache2

For httpd (Apache):

ps -eo comm,etime,user | grep httpd

With the -e flag, you select all processes and the -o flag lets you customize the output, showing the command, execution time, and the process owner. This method is a quick way to see how long Apache has been running, right down to the second.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.