AWStats: Advanced Web Statistics on Debian
Yes, setting up a quick Matomo instance is indeed one of the first things that comes to (my) mind when launching a new site. Including relaunches that is, such as this one, where I’ve been moving from WordPress to a minimalist static site based on Hugo.
Getting rid of all the clutter that a semi-bloated WordPress site brings to the table feels liberating. Now I realize that focusing on the bare essentials makes you far more effective and boosts your performance. So then, what we gonna do for Webstats and Analytics?
- No Trackers
- No Cookies
- GDPR Compliant
- Privacy Protection
Considering that I’m not particularly keen on gathering too much data, more like keeping a basic overview of traffic. For this, a simple reporting tool parsing the Apache logs, rendering these in HTML or XML would be perfectly sufficient.
Let’s dive into our apt-universe and check out our old friend AWStats - install it on a Debian 10 Buster Linux server and see if that helps. AWStats has been around for more than 20 years, and it’s one of the pieces of WebWare that I still remember from back in the old days.
Oh, and it’s written in Perl! 😎
AWStats - Advanced Web Statistics
So what is AWStats? Let’s look at this:
AWStats is an open source Web analytics reporting tool, suitable for analyzing data from Internet services such as web, streaming media, mail, and FTP servers. AWStats parses and analyzes server log files, producing HTML reports. Data is visually presented within reports by tables and bar graphs. Static reports can be created through a command line interface, and on-demand reporting is supported through a Web browser CGI program.
Installing AWStats on Debian 10 Buster
As usual, installing stuff is easy in the Debian-Universe:
$ apt install awstats
We move on to configure AWStats via the main configuration and the Apache-Conf.
First let’s edit the main configuration:
Pretty straight forward, make sure you add your
Then let’s look at the awstats.conf Apache Conf in
$ sudo /usr/lib/cgi-bin/awstats.pl -config=danten.io -update
Create/Update database for config "/etc/awstats/awstats.conf" by AWStats version 7.6 (build 20161204) From data in log file "/var/log/apache2/access.log"... Phase 1 : First bypass old records, searching new record... Searching new records from beginning of log file... Phase 2 : Now process new records (Flush history on disk after 20000 hosts)... Reverse DNS lookup for ::1 not available without ipv6 plugin enabled. Jumped lines in file: 0 Parsed lines in file: 1742 Found 0 dropped records, Found 0 comments, Found 0 blank records, Found 4 corrupted records, Found 0 old records, Found 1738 new qualified records.
$ a2enmod cgi
Enabling module cgi.
To activate the new configuration, you need to run:
$ systemctl apache2 restart
Then we’ll adjust our SSL parameters
$ vim /etc/apache2/conf-enabled/ssl-params.conf
Now let’s check if it works, visit yoursite.abc/awstats/
If all looks good, we’ll automate the report generation.
Setup A Cron Job To Automatically Update Your AWStats Frequently
Automatically added to
#MAILTO=root */10 * * * * www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh # Generate static reports: 10 03 * * * www-data [ -x /usr/share/awstats/tools/buildstatic.sh ] && /usr/share/awstats/tools/buildstatic.sh
So Cron runs all fine, but some errors:
Error while processing /etc/awstats/awstats.conf Create/Update database for config "/etc/awstats/awstats.conf" by AWStats version 7.6 (build 20161204) >From data in log file "/var/log/apache2/access.log"... Error: Couldn't open server log file "/var/log/apache2/access.log" : Permission denied Setup ('/etc/awstats/awstats.conf' file, web server or permissions) may be wrong.
Fallback to RTFM, from the README:
As AWStats is used both as a CGI-script and offline, it is by default run as uid=www-data in cron jobs so that generated files are accessible from CGI as well. By default Apache stores (since version 1.3.22-1) logfiles with uid=root and gid=adm, so you need to either... 1) Change the rights of the logfiles so that www-data has at least read access. For example: * change line in /etc/logrotate.d/apache2 to: "create 644 root adm" * change permissions of existing files: chmod 644 /var/log/apache2/*.log
That helps, all running smooth.
Secure Your AWStats via htaccess
Let’s secure the directory via htaccess in
And voilà, all set up and good.
AWStats - Conclusion & Verdict
It’s OK to install, though could have been smoother. AWStats is low on resources and provides a basic overview of your website traffic. Don’t expect too much of AWStats, some features don’t seem to work out of the box but I’m not willing to spend too much time trying to figure it out either.
Another alternative here is the good old Webalizer which is easier to install, better structured and offers a similar statistical reporting of your Apache logs.
AWStats is OK if all you need is to check visitor stats of your small/medium site once in a while, but should you have further needs and requirements, if you run a commercial site then you’d want to install Matomo - the open source Google Analytics alternative.
#Apache #Analytics #Debian