I never used “apachectl fullstatus” before. To get httpd status, I used “service httpd status” or “service httpd status -l” or “systemctl status httpd”. But now, I want to get more information about apache. You may hear about apache2ctl, but that command does not exist on my CentOS 7, although my apache version is 2.4. I think apache2ctl only exists on Ubuntu or Debian, while apachectl is the corresponding one on CentOS and Redhat.
To use “apachectl fullstatus”, you need to install the “links” package first(not installed by default on CentOS). How does “apachectl fullstatus” work? Well, the apachectl is actually a readable shell script /usr/sbin/apachectl. You can open it to see how it works. The “apachectl fullstatus” will access the url http://localhost:80/server-status to get the status of apache on your server. The url is specified by the STATUSURL variable in /usr/sbin/apachectl, and you can edit the script to change the value of that variable. The host part of that url does not matter actually. If you host several websites on your server, you can use any of them as the host such as http://domainhostseotool/server-status. The status is for httpd, not for particular website.
To get status report of your apache, you need to load the status_module when httpd starts. You need to add the following line to /etc/httpd/conf.modules.d/00-base.conf if have not already done:
LoadModule status_module modules/mod_status.so
After restarting httpd, use the following command to see if the status_module is actually loaded:
httpd -M | grep status
The output would be:
module ssl_module is already loaded, skipping
status_module (shared)
But now if you issue the “apachectl fullstatus” command, you may get the error:
Forbidden
You don’t have permission to access /server-status on this server.
That is because we have not set the handler for the url /server-status. We need to associate the url “/server-status” with the built-in handler server-status as follows:
<IfModule mod_status.c>
<Location “/server-status”>
SetHandler server-status
</Location>
</IfModule>
The Location directive is outside any virtual host; whenever the url is matched by “/server-status”, the directives inside <Location></Location> block are applied, and the server-status handler is called to handle this url. The STATUSURL used by “apachectl fullstatus” command is http://localhost:80/server-status, the path of the url is matched with that in the Location directive, so the server-status handler is called . You can also open a browser to visit http://domainhostseotool.com/server-status, and that url is also handled with the server-status handler and the apache status will be displayed on your browser. If you do not want somebody else on the internet to get your http server’s report, you need to exert some restriction inside the <Location></Location> block.
<IfModule mod_status.c>
<Location “/server-status”>
SetHandler server-status
Require local
</Location>
</IfModule>
Do not use the “Allow” directive or the “Deny” directive in apache 2.4. Instead, you should use the “Require” directive although the name of this directive is very obscure. The stuff follows the Require keyword is so called authorization provider, which decides whether a request for a resource is permitted or not(access control). Here, “Require local” means only request from local machine(the machine where httpd is running, or the connection from 127.0.0.1/8, ::1, or the same ip as the server) is allowed for the resource “/server-status”. Don’t mistake by “Require localhost” because that is a syntax error and httpd won’t start. You can also use “Require ip 127.0.0.1 ::1″ to restrict to local access. But “Require ip 127.0.0.1″ won’t work, because the “localhost” in STATUSURL will be resolved to ::1 if ipv6 is enabled.
The output of “apachectl fullstatus” would be like this:
- Current Time: Monday, 14-Nov-2022 10:16:18 EST
- Restart Time: Monday, 14-Nov-2022 10:15:40 EST
- Parent Server Config. Generation: 1
- Parent Server MPM Generation: 0
- Server uptime: 37 seconds
- Server load: 0.01 0.04 0.05
- Total accesses: 1 – Total Traffic: 3 kB
- CPU Usage: u0 s0 cu0 cs0
- .027 requests/sec – 83 B/second – 3072 B/request
- 1 requests currently being processed, 5 idle workers
1 2 3 4 |
___W__.......................................................... ................................................................ ................................................................ ................................................................ |
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
Srv | PID | Acc | M | CPU | SS | Req | Conn | Child | Slot | Client | VHost | Request |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0-0 | 32654 | 0/1/1 | _ | 0.00 | 28 | 0 | 0.0 | 0.00 | 0.00 | xx.xx.xx.xx | localhost:80 | NULL |
3-0 | 32657 | 0/0/0 | W | 0.00 | 0 | 0 | 0.0 | 0.00 | 0.00 | yy.yy.yy.yy | domainhostseotool:80 | GET /server-status HTTP/1.1 |
Srv | Child Server number – generation |
---|---|
PID | OS process ID |
Acc | Number of accesses this connection / this child / this slot |
M | Mode of operation |
CPU | CPU usage, number of seconds |
SS | Seconds since beginning of most recent request |
Req | Milliseconds required to process most recent request |
Conn | Kilobytes transferred this connection |
Child | Megabytes transferred this child |
Slot | Total megabytes transferred this slot |
You can see a lot of information from the status report. The most important piece of information you get is who is requesting which url of which website now.