Monitor apache using mod_status on Ubuntu

Apache installation on Ubuntu Linux automatically installs mod_status also. mod_status can be used to view server activities and performance from a web interface. Here are quick steps to get started with mod_status.

  1. First ensure if you have mod_status installed. Assuming you have apache2 installed run the following on command line.

    $ apache2ctl -M | grep status

    Note that apache2ctl -M lists all apache loaded modules.

  2. mod_status comes with a default config (/etc/apache2/mods-available/status.conf) which is only accessible from localhost. Here is how the config entry looks like:
            <Location /server-status>
                    SetHandler server-status
                    Require local
                    #Require ip
  3. To setup mod_status remote access with basic http auth add the following apache config. Note that you will have to create /etc/auth-file and a user in it. You can follow steps mentioned in tutorial Apache – add basic auth to a location or directory.
    <IfModule mod_status.c>
      <Location /my-server-status>
        SetHandler server-status
        AuthType Basic
        AuthName "Restricted Resource"
        AuthBasicProvider file
        AuthUserFile /etc/auth-file
        Require valid-user
  4. In case you are using wordpress or similar such software where every request is routed to index.php using .htaccess, you can add the following config to .htaccess before RewriteRule entry

    RewriteCond %{REQUEST_URI} !^/my-server-status$
    RewriteRule . /index.php [L]
  5. Now restart apache and access the /my-server-status page. You should be able to see the server status page with all requests being handled by Apache at that time. Here is how it will look like:
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments