Simple Apache Log Analysis
You weren’t asked to accept any cookies when you landed on this page, and that’s because I don’t have any trackers or cookies on my website. I like to keep it simple and I value privacy. However, it would be nice to have some very high-level data to know if anyone is actually looking at my website.
My needs are:
- Know if anyone is actually looking at my website,
- what do visitors find interesting,
- and where are visitors coming from, at a country level.
So had a look at two very simple http log analysers that’d give me just that, GoAccess and Webalizer.
GoAccess
GoAccess Setup
I ended up settling on GoAccess. It’s a simple command line utility that parses your http log file, Apache in my case, and generates some high-level analytics. You can view the analytics in a terminal which is cool as hell, or output it to HTML, and even JSON!
To get GoAccess going you need to install it and make some changes to it’s configuration file.
I’m on FreeBSD which has a GoAccess package available. I also installed groff so that I can read the GoAccess manual pages in my terminal.
1[root@thisbe /home/bradley]# pkg search goaccess
2goaccess-1.9.3_1 Real-time web log analyzer
3[root@thisbe /home/bradley]# pkg install goaccess
4[root@thisbe /home/bradley]# pkg install groff
Then make updates to the goaccess.conf file to configure date, time and log formats. Keep in mind your formatting may differ to mine. On FreeBSD the config file is /usr/local/etc/goaccess/goaccess.conf
1time-format %H:%M:%S
2date-format %d/%b/%Y
3log-format %h %^[%d:%t %^] "%r" %s %b
Generate a GoAccess report
Now you can generate a report
1[bradley@thisbe ~/public_html/stats]$ goaccess /var/log/httpd-access.log -a -o ./index.html
Adding country detail to GoAccess
If you want country detail in your report, you need to download a database that maps IP addresses to locations. You’ll find a database on the db-ip website. Download the database, I put mine in /usr/local/share/GeoIP.
1[root@thisbe ~]# mkdir /usr/local/share/GeoIP
2[root@thisbe ~]# cd /usr/local/share/GeoIP/
3[root@thisbe /usr/local/share/GeoIP]# wget https://download.db-ip.com/free/dbip-city-lite-2025-04.mmdb.gz
4Connecting to download.db-ip.com (download.db-ip.com)|104.26.5.15|:443... connected.
5Saving to: ‘dbip-city-lite-2025-04.mmdb.gz’
62025-04-20 17:46:53 (63.0 MB/s) - ‘dbip-city-lite-2025-04.mmdb.gz’ saved [55185200/55185200]
7[root@thisbe /usr/local/share/GeoIP]# gunzip dbip-city-lite-2025-04.mmdb.gz
8[root@thisbe /usr/local/share/GeoIP]# ln -s dbip-city-lite-2025-04.mmdb GeoLiteCity.dat
The routing of IP addresses is constantly moving between countries. You’ll need to periodically download this database to keep the location data up-to-date. I plan on adding a cron job to fetch this file once a week. It’ll simply repeat the steps in the code block above.
Now edit the goaccess.conf file and tell it where you’ve put the database.
1[root@thisbe /usr/local/etc/goaccess]# vi goaccess.conf
2geoip-database /usr/local/share/GeoIP/GeoLiteCity.dat
Webalizer
I used to use Webalizer a lot. It’s been around longer than I can remember! Sadly, however, some of it’s resources are no longer available, including it’s original project website and updates to it’s native IP location database. Nonetheless, it still works and you can get it going with the following steps.
Generate a Webalizer report
Generating a report with Webalizer is easy.
1webalizer [logfile path]
Adding country detail to Webalizer
Adding country detail to Webalizer is similar to GoAccess, and you can use the same IP location database. So assuming you’ve already downloaded the database using the steps above, this is how you configure Webalizer.
First, fetch some flag graphics and place it into the folder where you’ll be generating your Webalizer reports. I got mine from Dosboot.
1[bradley@thisbe ~/public_html/stats]$ wget https://dosboot.org/files/webalizer-flags.tgz
2Saving to: ‘webalizer-flags.tgz’
3[bradley@thisbe ~/public_html/stats]$ gunzip webalizer-flags.tgz
4[bradley@thisbe ~/public_html/stats]$ tar zxf webalizer-flags.tar
Then edit the webalizer configuration file and configure the following values in webalizer.conf
1[root@thisbe ~]# cd /usr/local/etc/
2[root@thisbe /usr/local/etc]# vi webalizer.conf
3GeoDB no
4CountryFlags yes
5FlagDir /usr/local/share/geolizer-dosboot/flags
6GeoIP yes
7GeoIPDatabase /usr/local/share/GeoIP/GeoLiteCity.dat
And that’s it. Now Webalizer will generate a table of location data by country, and a super cool retro pie graph too!