AWStats on FreeBSD

AWStats Logo

AWStats PreRequisites:

Since AWStats is a web server log file analyzer, the first prerequisite is a fully functional web server.  In our case, it is Apache 2.4 on a FreeBSD 10 Server.  Additionally, the web server should have the cgi_module loaded.  Also, if geographical data is desired, then the additional port – p5-geo-ip is required.


Install AWStats:

# portsnap fetch update
# cd /usr/ports/www/awstats
# make install clean


Install p5-Geo-IP:

# cd /usr/ports/net/p5-Geo-IP
# make install clean


Configure Apache httpd.conf:

Uncomment the following to load the cgi module:

LoadModule cgi_module libexec/apache24/


Uncomment the following to use combined log file format:

CustomLog "/var/log/httpd-access.log" combined


Comment the following to not use the common log file format:

#CustomLog "/var/log/httpd-access.log" common


Add the following to the bottom of /usr/local/etc/apache24/httpd.conf:

Alias /awstatsclasses "/usr/local/www/awstats/classes/"
Alias /awstatscss "/usr/local/www/awstats/css/"
Alias /awstatsicons "/usr/local/www/awstats/icon/"
ScriptAlias /awstats/ "/usr/local/www/awstats/cgi-bin/"

     <Directory "/usr/local/www/awstats/">
         Options None
         AllowOverride None
         Require all granted

     <Directory "/usr/local/www/awstats/cgi-bin/"> 
         Options ExecCGI
         SetHandler cgi-script


Configure Apache httpd-ssl.conf:

If using SSL, ensure the CustomLog Combined Format is utilized.  Change the following line in /usr/local/etc/apache24/extra/httpd-ssl.conf file.

CustomLog "/var/log/httpd-access.log" combined
#TransferLog "/var/log/httpd-access.log"


Download GeoIP.dat.gz & GeoLiteCity.dat.gz:

cd /usr/local/share/GeoIP
# fetch
# fetch
# fetch
# gunzip GeoIP.dat.gz 
# gunzip GeoLiteCity.dat.gz
# gunzip GeoIPASNum.dat.gz


Configure AWStats:

Create Configuration File for web site:

# cd /usr/local/www/awstats/cgi-bin
# cp awstats.model.conf


Edit and change the following parameters:

HostAliases=" localhost REGEX[myserver\.com$]"
LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat"
LoadPlugin="geoip_asn_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoIPASNum.dat+"

Create data directory:

# mkdir /usr/local/www/awstats/data


Process log files:

# /usr/local/www/awstats/cgi-bin/ -update


Create Cron Job to process log files:

# 50 9 * * * /usr/local/www/awstats/cgi-bin/ -update >/dev/null


View the Results:   —-Please substitue your own domain!


Log Notes:

Since the Apache Log Files are rotated using newsyslog.conf, I utilized the archived log file, httpd-access.log.1, when importing the data to AWStats.  The Log Files in /var/log are as follows:


Updating GeoLite Databases:

The port /net/GeoIP installed a file,, located at /usr/local/bin/ to update the open source databases from  The script, if executed, will update the GeoIP.dat and GeoIPv6.dat automatically without additional configuration.  In order to update the GeoLite City and the GeoLite ASN databases, you must enable them by setting GEOIP_FETCH_CITY and GEOIP_FETCH_ASN in your environment.  Read the for details.

Here are the setting in my configuration:


The script can be run manually to check if the files are downloaded properly.  Once satisfied with the results, you can create a crontab entry to automate running the script on a schedule.  MaxMind updates the open source databases on the second Tuesday of each month so schedule your crontab entry to reflect this information.


crontab -e:

This is my crontab entry:

30     09     *      *      4      /usr/local/bin/ >/dev/null



Installing and configuring AWStats was fairly easy once I familiarized myself with the configuration files and, of course, by trying different combinations until it was working as expected.  This is a compilation of that effort.




3 thoughts on “AWStats on FreeBSD”

  1. I’ve been browsing online more than three hours as of late, yet I never found
    any attention-grabbing article like yours.
    It is lovely worth enough for me. In my opinion, if all webmasters and
    bloggers made good content as you probably did, the net
    will be a lot more useful than ever before.

Leave a Reply

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