Understanding the Apache Service Status

Reading Time: 5 minutes

In this article, we will be reviewing the Apache Service Status. Sometimes checking the performance of a server can be difficult. Apache has built-in utilities that assist in monitoring the usage and performance of Apache. Apache Status also provides information that aids in performance auditing and control tuning.

Using the Systemctl Status

Accessing the Apache status is rather easy. You will have to SSH into the server as root and then type in the following command in at the command prompt:

root@host [~]# systemctl status httpd.service

Running that command on a cPanel server will return data similar to the following:

root@host [~]# systemctl status httpd
 httpd.service - Apache web server managed by cPanel EasyApache
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-10-02 05:04:55 EDT; 6 days ago
 Main PID: 1587 (httpd)
    Tasks: 325
   Memory: 102.1M
   CGroup: /system.slice/httpd.service
           ├─  1587 /usr/sbin/httpd -k start
           ├─100800 /usr/local/cpanel/bin/splitlogs --dir=/etc/apache2/logs/domlogs --main=host.domain.com --suffix=-byte...
           ├─100801 /usr/local/cpanel/bin/splitlogs --dir=/etc/apache2/logs/domlogs --main=host.domain.com --mainout=/etc...
           ├─100802 /usr/sbin/httpd -k start
           ├─100803 /usr/local/cpanel/3rdparty/bin/perl /usr/local/cpanel/bin/leechprotect
           ├─100804 /usr/sbin/httpd -k start
           ├─100805 /usr/sbin/httpd -k start
           ├─100807 /usr/sbin/httpd -k start
           ├─100822 /usr/sbin/httpd -k start
           └─100858 /usr/sbin/httpd -k start
root@host [~]# 

The purpose of the bolded sections is as follows.

Loaded: This is the location for the configuration file.
Active: This indicates that the service is active and running.
Main PID: This is the main Apache process ID.
Tasks: The overall number of tasks associated with the process.
Memory: The amount of memory the processes are using.
CGroup Block: This section denotes the control group of apache’s child processes (including splitlogs in cPanel)

Running the systemctl status httpd.service command on an InterWorx server will return something similar to the following:

[root@host ~]# systemctl status httpd.service
 httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/httpd.service.d
           └─limits.conf
   Active: active (running) since Fri 2019-10-04 13:16:37 EDT; 4 days ago
 Main PID: 68308 (httpd)
   Status: "Total requests: 3950; Idle/Busy workers 100/0;Requests/sec: 0.0109; Bytes served/sec:   6 B/sec"
   CGroup: /system.slice/httpd.service
           ├─43782 /usr/sbin/rotatelogs -l -f /home/user/var/domain.com/logs/error-ssl-%Y-%m-%d.log 86400
           ├─43784 /usr/sbin/rotatelogs -l -f /home/user/var/domain.com/logs/error-%Y-%m-%d.log 86400
           ├─43786 /usr/sbin/rotatelogs -l -f /home/user/var/domain.com/logs/transfer-ssl-%Y-%m-%d.log 86400
           ├─43787 /usr/sbin/rotatelogs -l -f /home/user/var/domain.com/logs/transfer-%Y-%m-%d.log 86400
           ├─43792 /usr/sbin/httpd -DSSL -DFOREGROUND
           ├─43819 /usr/sbin/fcgi- -DSSL -DFOREGROUND
           ├─43820 /usr/sbin/httpd -DSSL -DFOREGROUND
           ├─43821 /usr/sbin/httpd -DSSL -DFOREGROUND
           ├─43857 /usr/sbin/httpd -DSSL -DFOREGROUND
           ├─68308 /usr/sbin/httpd -DSSL -DFOREGROUND
           └─70722 /usr/sbin/httpd -DSSL -DFOREGROUND

Oct 04 13:16:37 host.domain.com systemd[1]: Starting The Apache HTTP Server...
Oct 04 13:16:37 host.domain.com systemd[1]: Started The Apache HTTP Server.
Oct 06 05:35:19 host.domain.com systemd[1]: Reloading The Apache HTTP Server.
Oct 06 05:35:19 host.domain.com systemd[1]: Reloaded The Apache HTTP Server.
[root@host ~]# 

The purpose of the bolded sections is as follows.

Loaded: This is the location for the configuration file.
Drop-In: This file defines the open file limit for Apache.
Active: This indicates that the service is active and running.
Main PID: This is the primary Apache process ID.
Tasks: The overall number of tasks associated with the process.
Memory: The amount of memory the processes are using.
CGroup Block: This section denotes the control group of Apache’s child processes (including log rotation)

Using the Apachectl Status

The apachectl command is the forward-facing front end to the Apache http server. It is intended to help an admin control the functions of the Apache (httpd) daemon.

The apachectl script can function in two modes. First, it acts as a simple front-end to the httpd command that sets needed environment variables, which then invokes the httpd service, passing along any command-line arguments. Secondly, apachectl acts as a SysV init processing script, using one-word arguments like start, restart, and stop, and translating them into appropriate commands to httpd.

The apachectl command uses the following arguments to return information:

  • Start: This argument starts the Apache httpd daemon.
  • Stop: This argument stops the Apache httpd daemon.
  • Restart: This argument restarts the Apache httpd daemon. If the service is not running, this command starts the https service. It also checks the configuration files before launching the service to ensure the service does not die.
  • Fullstatus: This argument provides a full status report from mod_status. For this command to work, you need to have mod_status enabled on your server. A text-based browser such as Lynx can be used to view this info. 
  • Status: This argument displays a short status report that is similar to the fullstatus argument, except that the list of http requests currently being served is not shown.
  • Graceful: This argument gracefully restarts the httpd service. If the service is not running, it is started.
  • Graceful-stop: This argument gracefully stops the Apache httpd service. This argument differs from a typical stop argument as it will leave connections open and not stop them.
  • Configtest: This argument runs a configuration check on the http.conf file, and with either report, the syntax is ok, or it will provide detailed information about any syntax errors it finds.
  • Startssl: This argument starts the httpd service with SSL support enabled. This will require an edit to the config file to include the appropriate directives and then use the standard apachectl start.

Example:

root@host [~]# apachectl status

The first part of the Apache status provides information about Apache’s version and when the service was built. It also denotes the MPM modules (Multi-Processing Modules) it is using. Additionally, the command also notes the current time, when httpd was last restarted, the servers uptime, load, and other multiple types of info relevant to the status of the server. The information can also help to determine if Apache cannot serve up any more requests due to the lack of idle workers.

<pre>root@host [~]# apachectl status
                  Apache Server Status for localhost (via ::1)
   Server Version: Apache/2.4.41 (cPanel) OpenSSL/1.0.2t mod_bwlimited/1.4
   Server MPM: worker
   Server Built: Sep 16 2019 17:10:52
----------------------------------------------------------------------
   Current Time: Wednesday, 09-Oct-2019 09:36:04 EDT
   Restart Time: Wednesday, 02-Oct-2019 05:04:55 EDT
   Parent Server Config. Generation: 12
   Parent Server MPM Generation: 11
   Server uptime: 7 days 4 hours 31 minutes 9 seconds
   Server load: 0.08 0.05 0.05
   Total accesses: 184569 - Total Traffic: 1.4 GB - Total Duration: 101212423
   CPU Usage: u67.46 s30.84 cu231.76 cs74.02 - .0651% CPU load
   .297 requests/sec - 2445 B/second - 8.0 kB/request - 548.372 ms/request
   3 requests currently being processed, 122 idle workers

 ___________________W______________________________..............
 ..........._____________________________________________________
 __________________W__K

 Scoreboard Key:
 "_" Waiting for Connection, "S" Starting up, "R" Reading Request,
 "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
 "C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process
root@host [~]# 
</pre>

The second half of the status shows a text representation of what all the Apache workers are doing at a given moment. The keys below it tell what each letter stands for. This information can assist in troubleshooting Apache when it is having trouble keeping up with traffic. For example, if Apache is having difficulty serving all the requests that are being made of the server. If the Apache status had a bunch of “K”s listed (for requests that are kept alive), the KeepAlive variables in the httpd.conf could be tweaked.

Using Other Apache Options

The regular Apache status gives a solid amount of good information, but other Apache options provide more specific information. To view these options, we can run:

systemctl status httpd.service -h

this provides an output similar to the following:

<pre>[root@host httpd.service.d]# systemctl status httpd.service -h
systemctl [OPTIONS...] {COMMAND} ...

Query or send control commands to the systemd manager.

  -h --help           Show this help
     --version        Show package version
     --system         Connect to system manager
  -H --host=[USER@]HOST
                      Operate on remote host
  -M --machine=CONTAINER
                      Operate on local container
  -t --type=TYPE      List units of a particular type
     --state=STATE    List units with particular LOAD or SUB or ACTIVE state
  -p --property=NAME  Show only properties by this name
  -a --all            Show all loaded units/properties, including dead/empty
                      ones. To list all units installed on the system, use
                      the 'list-unit-files' command instead.
  -l --full           Don't ellipsize unit names on output
  -r --recursive      Show unit list of host and local containers
     --reverse        Show reverse dependencies with 'list-dependencies'
     --job-mode=MODE  Specify how to deal with already queued jobs, when
                      queueing a new job
     --show-types     When showing sockets, explicitly show their type
  -i --ignore-inhibitors
                      When shutting down or sleeping, ignore inhibitors
     --kill-who=WHO   Who to send signal to
  -s --signal=SIGNAL  Which signal to send
     --now            Start or stop unit in addition to enabling or disabling it
</pre>

This option provides information about all of the arguments available.

While the Apache status and fullstatus commands may seem like an overwhelming amount of information, that information can assist in diagnosing many types of problems with Apache.


Liquid Web’s Heroic Support is always available to assist customers with this or any other issue. If you need any assistance please contact us on our Toll-Free number 1.800.580.4985 / International 517.322.0434, open a support ticket at support@liquidweb.com or, reach out via chat. We’re standing by to help!

Author Bio

About the Author: David Singer

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Get 33% off the first 3 months on a new Dedicated server! Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7x365 Support