Display Your Apache Server Status As HTML Webpage
Diagnosing and fixing Apache issues can be a fucking nightmare (excuse the french). However one thing you might want to do is allow yourself access to view key Apache stats on a webpage rather than have to SSH in and use the console.
If you read some articles on the web to set this up it's as simple as adding the following lines to your main apache2.conf or httpd.conf file.
Depending on your server you will need to go into /etc/apache2/apache2.conf or etc/httpd/conf/httpd.conf and then adding the following lines.
# Allow server status reports, with the URL of http://dv-example.com/server-status # Change the ".dv-example.com" to match your domain to enable. ExtendedStatus on
SetHandler server-status Order Deny,Allow Deny from all Allow from mywebsite.com
Or if you wanted to only allow your own IP address to access the page you could do something like this.
# Allow server status reports, with the IP addresss you want to allow access ExtendedStatus on
SetHandler server-status Order Deny,Allow Deny from all Allow from 22.214.171.124
However when I tried either of these approaches I was just met with an error message:
Forbidden You don't have permission to access /server-status on this server.
At the bottom of my main apache2.conf file I noticed the lines
# Include generic snippets of statements Include /etc/apache2/conf.d/
Therefore I went into that folder and was met with 3 other files:
The top of the security file had these lines.
# Disable access to the entire file system except for the directories that # are explicitly allowed later. # # This currently breaks the configurations that come with some web application # Debian packages. It will be made the default for the release after lenny. # #
# AllowOverride None # Order Deny,Allow # Deny from all #
So it seems that the main file was loading in these other files and the security file was blocking access to all other directories. By adding my rule to the top conf file the security file just over-ruled it again which caused the 403 error. Therefore I added the rules to the bottom of the security file and hey presto it worked.
Now I can access one of my domains to find my apache info. However I found that due to most of my sites on this virtual server using WordPress their ISAPI rules prevent a simple mysite.com/server-status from working.
WordPress is obviously trying to resolve the URL to a page, post or category list.
Therefore if you have got this problem you might need to use a domain not full of rules or create a rule that bypasses the WordPress guff.
Once you get it working you will get Apache info such as the following.
Current Time: Saturday, 31-Aug-2013 08:28:06 BST Restart Time: Saturday, 31-Aug-2013 08:15:13 BST Parent Server Generation: 0 Server uptime: 12 minutes 53 seconds Total accesses: 622 - Total Traffic: 4.2 MB CPU Usage: u26.65 s3.24 cu0 cs0 - 3.87% CPU load .805 requests/sec - 5.5 kB/second - 6.9 kB/request 3 requests currently being processed, 4 idle workers
Plus lots of info about current HTTP requests, CPU usage and session info.
It is well worth doing if you need info about your server and you are away from your SSH console.