Installing awstats on Ubuntu Feisty

I started to use awstats for creating the site statistics on our server. After installing the ubuntu package, there are still a few things that I had to do:

  1. Install libnet-ip-perl and libgeo-ipfree-perl in order to map the dns entries to countries.

    in order to use the free, but non-open source versions of GeoIP.

  2. Since I use vhosts, I put for every vhost one configuration file into the /etc/awstats/ directory.
  3. Into the vhost-specific configuration file I only put directives that are different from the default configuration file /etc/awstats/awstats.conf. For my own vhost ( these directives are as follows:

    DefaultFile="index.html index.php"

    If you want to use the non-OSS GeoIP stuff, replace the last line by the following:

    LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/perl/5.8.8/Geo/IP/GeoIP.dat"
    LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/perl/5.8.8/Geo/IP/GeoLiteCity.dat"
    LoadPlugin="geoip_org_maxmind GEOIP_STANDARD /usr/local/share/perl/5.8.8/Geo/IP/GeoIPASNum.dat"

    Compile the GeoIP-1.4.2 stuff according to the INSTALL file. You probably need to get some stuff first to be able to do the compilation. Execute apt-get install build-essential Compile Geo-IP-1.27 according to the INSTALL file. Unzip the 3 databases and put them into the /usr/local/share/perl/5.8.8/Geo/IP/ directory.

  4. In order to protect the statistics I limit access to authenticated users.
    The following lines has to be added to the vhost-specific apache configuration file /etc/apache2/sites-available/
    <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    AuthType basic #added line
    AuthName "cgi-bin restricted" #added line
    AuthUserFile /etc/apache2/.htpasswd #added line
    <Files> #added line
    Require valid-user #added line
    </Files> #added line

    The you need to create the /etc/apache2/.htpasswd file and add a user password with the command:

    htpasswd -c /etc/apache2/.htpasswd username

  5. Now everything works apart from the images which awstats expects to be in the icon subdirectory of the document root for the vhost. I just created a link:

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

    On some Ubutu installs the log files cannot be accessed and even if you change the permissions to
    chomd -R 755 /var/log/apache2 they keep being switched back by the logrotation script. In order to fix that read this post.