Daily statistics in AwStats

AwStats is a log file parser written in perl, with which you can keep statistics of site visits based on information from log files.

As a rule, awstats displays general information for the week, month. But what to do if you need to display information about visiting the site for a specific day.

A similar trick will be discussed further on the example of a server based on Linux Ubuntu with Apache2.

First, install AwStats:

apt-get install awstats libapache2-mod-perl2

Create website config:

cp /etc/awstats/awstats.conf /etc/awstats/awstats.**website.com**.conf

Edit the file accordingly:

LogFile="/var/log/apache2/access.log" #path to logfile;
LogFormat=1 #for full statistics;
SiteDomain="website.com” #domainname;
HostAliases="www.website.com website.com" #site aliases
AllowFullYearView=3
DNSLookup=0

That is it. Next enable AwStats in Apache:

cp /usr/share/doc/awstats/examples/apache.conf /etc/apache2/conf.d/awstats.conf  
/etc/init.d/apache2 reload

Edit cron tab:

crontab -e

Create the following cron jobs:

0 2 * * * /usr/lib/cgi-bin/awstats.pl --config=/etc/awstats/awstats.website.com.conf -DatabaseBreak=day > /dev/null
0 2 * * * /usr/lib/cgi-bin/awstats.pl --config=/etc/awstats/awstats.website.com.conf -DatabaseBreak=month > /dev/null
0 2 * * * /usr/lib/cgi-bin/awstats.pl --config=/etc/awstats/awstats.website.com.conf -DatabaseBreak=year > /dev/null

It remains to create index.cgi that will provide the ability to select a range for displaying statistics. Create an index.cgi file in /usr/lib/cgi-bin/

The contents of the file are in the spoiler.

/usr/lib/cgi-bin/index.cgi

Make it executable and change the owner:

chmod 755 /usr/lib/cgi-bin/index.cgi
chown www-data:www-data /usr/lib/cgi-bin/index.cgi

Edit /etc/apache2/conf.d/awstats.conf with the following:

DirectoryIndex index.cgi

I got the same note for NginX