Tag Archive | htpasswd

Monitor Apache Web Server Load and Page Statistics

As a System Admin it becomes very important to check the Apache server statistics for performance and troubleshooting any issues

Apache’s mod_status can be used to provide these details
Apache’s mod_status shows a plain HTML page containing the information about current statistics of web server state including.

  •     Total number of incoming requests
  •     Total number of bytes and counts server
  •     CPU usage of Web server
  •     Server Load
  •     Server Uptime
  •     Total Traffic
  •     Total number of idle workers
  •     PIDs with respective client and many more.

By default the status page is disabled to hide internal information from unauthorized users.
=======================================================================================
Enable mod_status in Apache
The default Apache installation comes with mod_status enabled
To validate it .
a) login in to the Apache server
b) Navigate to the Apache configuration file ie /etc/httpd/conf/httpd.conf
[root@mqnode AppServer]# vi /etc/httpd/conf/httpd.conf
c) Search for the word “mod_status”
#LoadModule status_module modules/mod_status.so
If its commented then uncomment it
d) Restart the apache instance using

[root@mqnode AppServer]# service httpd stop
Stopping httpd:                                            [  OK  ]
[root@mqnode AppServer]# service httpd start
Starting httpd:                                            [  OK  ]

=======================================================================================
Configure server-status

1) Login the the Apche Server
2)Open the /etc/httpd/conf/httpd.conf
3) Search for server-status

# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Change the “.example.com” to match your domain to enable.
#
#<Location /server-status>
#    SetHandler server-status
#    Order deny,allow
#    Deny from all
#    Allow from .example.com
#</Location>

Remove the comment character (“#”) in front of each line.
Be careful about the “Allow from” line.
Here you can customize to put the IP address and fine tune the security to ensure that unauthorized access to server-status url
Recommended to use your IP address that you are connecting from.
You might also want to consider password-protecting this page using htpasswd.

4) We would use the htpasswd for security

5) Setup the htpasswd
[root@mqnode ~]# htpasswd -c /etc/httpd/conf/server-status-htpasswd status
New password:
Re-type new password:
Adding password for user status
[root@mqnode ~]# cat /etc/httpd/conf/server-status-htpasswd
status:hdtkPGbH2G81U

5) Use this  /etc/httpd/conf/server-status-htpasswd within the configurations for server-status in httpd.conf

<Location /server-status>
SetHandler server-status
AuthType basic
AuthName “Apache status”
AuthUserFile /etc/httpd/conf/server-status-htpasswd
Require valid-user
</Location>

Screenshot:status_3
6) Enable ExtendedStatus
The “ExtendedStatus” settings adds more information to the statistics page like, CPU usage, request per second, total traffic, etc.

7)  To enable it, edit the the same httpd.conf file and search for the word “Extended” and Uncomment the line and set the status “On” for ExtendedStatus directive.
ExtendedStatus On

8) Restart Apache
[root@mqnode ~]# service httpd restart
Stopping httpd:                                          [  OK  ]
Starting httpd:                                          [  OK  ]

9) Access mod_status Page
http://serveripaddress/server-status

status_1

It will prompt for the user name and password. Enter the Details

 

status_2