Document Actions

AWStats Install Guide

by David Hostetler [posted 20110209:12:31 (Wed)]

Step-by-step guide to installing and configuring awstats on gentoo.

The awstats documentation should be referenced, and supercedes any information provided here.  Note that this guide is geared towards using awstats with apache.

Process

  1. Presumably apache or something that you're going to track is already installed.  Awstats can't track the statistics of something that's not running.
  2. Install awstats.
    • emerge -avt awstats dev-libs/geoip
    • If you're using vhosts with apache, the emerge doesn't actually create a usable awstats instance, you have to use webapp-config to finish.
      • First, edit the webapp-config configuration file to ensure its defaults are appropriate.
        • vim /etc/vhosts/webapp-config
      • Now use webapp-config to install the instance of the application
        • webapp-config -I -h <vhostname> -u <username> -g <groupname> --secure -d <vhost_subdir> awstats x.y.z
        • Where <vhost_subdir> is a directory name under your vhost's rootdir where you want the instance to live, and x.y.z is the version of awstats that you're installing.
        • <username> and <groupname> are used to establish ownership of the files once they're installed.  You should specify the user/group under which your webserver (apache) runs.  Alternatively, omit these arguments and ensure that the corrsponding values are set correctly in /etc/vhosts/webapp-config.
        • An example of the above command is as follows:
        • webapp-config -I -h negativesum -u apache -g apache --secure -d raw/awstats awstats 6.9-r1
      • If that works successfully, you'll find all of the awstats files in <vhost_dir>/<vhost_subdir>.
      • Reference 'man webapp-config' and /etc/vhosts/webapp-config for further details.
  3. Configure awstats.
    • Copy /etc/awstats/awstats.model.conf to /etc/awstats/awstats.<yourdomain>.conf (i.e. awstats.negativesum.net.conf)
    • Edit awstats.<yourdomain>.conf as necessary.
      • SiteDomain="negativesum.net"
        
  4. Configure apache.
    • /etc/apache2/vhosts.d/00_default_vhost.conf
      • CustomLog /var/log/apache2/access_log combined
        ErrorLog /var/log/apache2/error_log
        
        # redirect awstats to https
        RewriteCond %{REQUEST_URI} ^/raw/awstats(.*)
        RewriteRule ^/rawe/awstats(.*)$ https://negativesum.net/raw/awstats$1 [R,L]
    • /etc/apache2/vhosts.d/00_default_ssl_vhost.conf
      • CustomLog /var/log/apache2/ssl_access_log combined
        ErrorLog /var/log/apache2/ssl_error_log
        
        # added -hoss: provides awstats
        #Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
        #Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
        #Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
        ScriptAlias /raw/awstats/cgi-bin/ /home/apache/vhosts/negativesum/cgi-bin/
        
        # This is to permit URL access to scripts/files in AWStats directory.
        <Directory "/home/apache/vhosts/negativesum/cgi-bin">
            Options None
            AllowOverride None
            Order allow,deny
            Allow from all
        
            AuthName        "Negativesum AWStats"
            AuthType        Basic
            AuthUserFile    /etc/apache2/apachepasswd
            AuthGroupFile   /etc/apache2/apachegroups
            Require         group awstats
        </Directory>
  5. Generate the reports.
  6. Point your browser at https://<yoursite>/cgi-bin/awstats.pl to see if things are kosher.
  7. Setup cron-based updates.  Piggy-backing on the apache logrotate hook is easy and effective.

    • Edit /etc/logrotate.d/apache:

      • /var/log/apache2/*log {
          missingok
          notifempty
          sharedscripts
          prerotate
          /usr/bin/awstats.pl -update -config=negativesum.net
          postrotate
          /etc/init.d/apache2 reload > /dev/null 2>&1 || true
          endscript
        }
        
  8. asdf

Finished!

Attachments