HOWTO Setup AWStats

From Research
Jump to navigation Jump to search

This shows how to setup awstats on an apache server with vhosting. Make sure you have the vhosts use variable set on Gentoo. This article is aimed for AWStats on tirpitz.

Install AWStats

# emerge awstats

Note: it's more fun to edit /etc/portage/package.use and add the geoip USE-flag.

Use webapp-config

The standard projects directory must be listed in /etc/vhosts/webapp-config using the VHOST_ROOT variable. Currently this is set for any project that exists in: /home/projects/*/htdocs, as most projects on tirpitz have their webspace here.

To setup another project, use webapp-config to add it to your project's htdocs directory:

# webapp-config -I -h <projectname> -u root -d /awstats awstats 6.5

For machines other than tirpitz you can install with this command, which will place your app under /var/www/localhost/htdocs:

# webapp-config -I -h localhost -d /awstats awstats 6.5

webapp-config will output a lot of text, ignore it.

Typical upgrade commands:

# webapp-config -U -d /awstats awstats 6.9

Apache VHost Configuration

Copy this following section into your vhost file: /etc/apache2/vhosts.d/<projectname>.conf

# awstats
Alias /awstats/classes "/usr/share/webapps/awstats/6.5/htdocs/classes/"
Alias /awstats/css "/usr/share/webapps/awstats/6.5/htdocs/css/"
Alias /awstats/icons "/usr/share/webapps/awstats/6.5/htdocs/icon/"
ScriptAlias /awstats/ "/usr/share/webapps/awstats/6.5/hostroot/cgi-bin/"
ScriptAlias /awstats "/usr/share/webapps/awstats/6.5/hostroot/cgi-bin/awstats.pl"
ScriptAlias /awstats.pl "/usr/share/webapps/awstats/6.5/hostroot/cgi-bin/awstats.pl"

<Directory "/usr/share/webapps/awstats/6.5/htdocs">
    Options None
    AllowOverride None
    <IfModule mod_access.c>
        Order allow,deny
        Allow from all
    </IfModule>
</Directory>
<Directory "/usr/share/webapps/awstats/6.5/hostroot/cgi-bin">
    Options ExecCGI
    AllowOverride None
    <IfModule mod_access.c>
        Order allow,deny
        Allow from all
    </IfModule>
</Directory>
# awstats

Create the AWStats Config File

# cd /etc/awstats
# cp awstats.researchtemplate.conf awstats.<projectname>.conf

Now edit that file to suit your project.

Note: most of this information is in your apache vhost file: /etc/apache/vhosts.d/<projectname>.conf

These are the variables you need to edit:

  • LogFile="/var/log/apache2/<projectname>/access_log"
  • SiteDomain="<projectname>.research.iat.sfu.ca"
  • HostAliases"<projectname>.research.iat.sfu.ca www.<projectname>.research.iat.sfu.ca localhost 127.0.0.1 REGEX[myserver\.com$]"

These HostAliases must match all ServerAliases in your vhosts config file!

  • DirData="/home/projects/<projectname>/htdocs/awstats

Un-comment (around line 1270):

LoadPlugin="geoip GEOIP_STANDARD"

Restart apache for the settings to take effect

# /etc/init.d/apache2 restart

Schedule Daily Log Updates

Add the project to the daily cronjob: /etc/cron.daily/awstats

/usr/share/webapps/awstats/6.5/hostroot/cgi-bin/awstats.pl -config=<projectname> -update

Run that command once for the logs to be analysed the first time.

If you prefer Hourly log-updates, then create a file /etc/cron.hourly/awstats with this sort of content:

#
# /etc/cron.hourly/awstats
#
# parses apache log-files, and prepares them for viewing
#

cd /var/www/localhost/cgi-bin/ && ./awstats.pl -config=localhost -update > /dev/null

Access the Stats Website

http://research.iat.sfu.ca/awstats.pl?config=<projectname>

For reference, the current awstats running on tirptitz can be found at:

http://research.iat.sfu.ca/awstats.pl?config=infrastructure