Forward

As of 2024, AWStats documentation is 5 or more years old.

Unfortuneatly, around 2020, MaxMind changed their database format from .dat to .mmdb. 

So the AWStats documentation won't show you how to setup the AWStats plugin new MaxMind GeoIP format (GeoLite2-City.mmdb).

But rest assured, AWStats has been updated by the developer community to read the new mmdb format and show city pages and hits.

I wrote this page to help other system administrators who are struggling to get AWStats running with MaxMind on cPanel/WHM servers.

I had a lot of trouble getting this to work on a AlmaLinux 9, cPanel/WHM server... mostly due to the @INC paths excluding anything outside of cPanel.

AWStats is installed via cPanel - so that won't be explained here.

You need to have a MaxMind database on your server. It is free, but you need to create an account and use a free licence key to automatically update the database. For info on how to do this see https://dev.maxmind.com/geoip/updating-databases

These instructions are commands through SSH, so if you don't have root access, this is not for you.

MaxMind GeoIP2 - for better AWStats

In the cPanel config file...

vi /usr/local/cpanel/etc/awstats.conf

 Add these lines - and comment out geoipfree.

LoadPlugin="geoip2_country /usr/share/GeoIP/GeoLite2-Country.mmdb"
LoadPlugin="geoip2_city /usr/share/GeoIP/GeoLite2-City.mmdb"

 The plugin comments mention that the perl module GEOIP2 needs to be installed... but rather than using cPanel's Perl Installer (it doesn't work well for this ) use YUM install...

yum install perl-GeoIP2 perl-MaxMind-DB-Reader-XS

If it won't install and you are getting errors of missing modules, delete all MaxMind and GeoIP2 perl directories, and erase the yum install...

find /usr -name MaxMind
find /usr -name GeoIP2
rm -rI ....path....
yum erase perl-GeoIP2 perl-MaxMind-DB-Reader-XS

 

For AlmaLinux 9 with a cPanel/WHM install  - you will need to edit the AWstats geoip2_country.pm and geoip2_city.pm plugin files to include these extra paths for  @INC.

vi /usr/local/cpanel/3rdparty/bin/plugins/geoip2_country.pm
vi /usr/local/cpanel/3rdparty/bin/plugins/geoip2_city.pm

 

Add these Line:

# Edit: organicwebs June 2024
# need to add perl libary outside of cPanel...
use lib '/usr/local/share/perl5/5.32';
use lib '/usr/local/lib64/perl5/5.32';
use lib '/usr/share/perl5/vendor_perl';

 

 To run logs for a user: and update the stats (as well as other cPanel stuff like quotas).

/scripts/runweblogs user

 

More info on cPanel AWstats files: