apt-get install awstats
cp /etc/awstats/awstats.conf /etc/awstats/awstats.www.mydomain.com.conf
Edit the following lines in the file:
LogFile="/path/to/your/domain/access.log" LogFormat=1 SiteDomain="www.mydomain.com" HostAliases="www.mydomain.com localhost 127.0.0.1"
Create the file /etc/apache2/conf.d/awstats with the following content. Files in this subdirectory are automatically included by the apache2 configuration file:
Alias /awstatsclasses "/usr/share/awstats/lib/" Alias /awstats-icon/ "/usr/share/awstats/icon/" Alias /awstatscss "/usr/share/doc/awstats/examples/css" ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ ScriptAlias /awstats/ /usr/lib/cgi-bin/ Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
You need to reload Apache to activate the Alias definitions.
Once you’ve made these changes you’ll want to build your initial statistics, which will be generated from the current logs on your machine:
/usr/lib/cgi-bin/awstats.pl -config=www.mydomain.com -update
Check your statistics at http://www.mydomain.com/awstats/awstats.pl
Edit the crontab file:
crontab -e
To update the stats every 15 minutes, enter the following cron job:
01,16,31,46 * * * * perl /usr/lib/cgi-bin/awstats.pl -config=www.mydomain.com -update
This updates the stats file /var/lib/awstats/awstats012009.www.mydomain.com.txt. Note that the first call might take quite some time depending on how large the log file is, whereas frequent following calls take very short time as the already processed information is skipped.
The stats file contains all the information which is displayed in the web frontend. If you enable a plugin, remember that already processed information is not affected by the plugin. To parse the whole logfile with the active plugin you need to delete the stats file first and generate a new one.
Add U(sers) and V(isits to the country statistics:
ShowDomainsStats=UVPHB
apt-get install libgeo-ip-perl
Use the -N option to only download if the file has been updated:
wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz gunzip GeoIP.dat.gz
Edit the following lines in /etc/awstats/awstats.www.mydomain.com.conf:
# disable DNS lookup DNSLookup=0 # enable GeoIP, path is relative to root of webserver (not document root!) LoadPlugin="geoip GEOIP_STANDARD /path/to/GeoIP.dat"
Delete the stats file /var/lib/awstats/awstats012009.www.mydomain.com.txt to force a rebuild of the stats with the additional information of the plugin.