Install AWStats on Debian

Install AWStats< to analyse Apache log files.

Installation

This article assumes that you have an Apache webserver installed and running already.

# apt-get install awstats

Configuration

Open /etc/awstats/awstats.conf for editing and change the following lines:

# This is where your Apache log goes
LogFile="/var/log/apache2/access.log"

# For Apache combined logs
LogFormat=1

# The main domain name used to reach the website
SiteDomain="www.example.com"

HostAliases="localhost 127.0.0.1"
DirIcons="./icon"

Create a webroot for awstats website:

# mkdir /var/www/awstats 
# ln -s /usr/share/awstats/icon /var/www/awstats/icon

Create a config file:

# touch /etc/apache2/sites-available/awstats.conf

Open the file above for editing and add the following lines:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName awstats.example.com

    DocumentRoot /var/www/awstats
    <Directory />
      AuthGroupFile /dev/null
      AuthType Basic
      AuthUserFile /var/www/awstats/.htpasswd
      AuthName "Access Restricted"
      Require valid-user
      AuthType Basic

      Order deny,allow
      Deny from all
      Allow from 10.0.0.0/8
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

      Order deny,allow
      Deny from all
      Allow from 10.0.0.0/8
    </Directory>
</VirtualHost>

Change the subnet above (10.0.0.0/8) to match your network configuration.

Create a new password .htpasswd file for user sandy for basic Apache authentication:

# htpasswd -c /var/www/awstats/.htpasswd sandy

Enable awstats website:

# cd /etc/apache2/sites-available/
# a2ensite awstats.conf

Test configuration:

# apachectl configtest
Syntax OK

Restart Apache:

# /etc/init.d/apache2 restart

Generate Reports

# /usr/lib/cgi-bin/awstats.pl -config=apache -update
# /usr/lib/cgi-bin/awstats.pl -config=apache -output -staticlink > /var/www/awstats/index.html

Generate reports automatically every hour:

# crontab -l
0 * * * * /usr/lib/cgi-bin/awstats.pl -config=apache -update
5 * * * * /usr/lib/cgi-bin/awstats.pl -config=apache -output -staticlink > /var/www/awstats/index.html

4 thoughts on “Install AWStats on Debian

Leave a Reply to Bernhard Cancel reply

Your email address will not be published. Required fields are marked *