Updated: 15 November 2026 · Applies to: DirectAdmin servers with AWStats; AWStats 7.9 tested
To get a country report in AWStats on DirectAdmin, either turn on DNSLookup=1 in the domain's AWStats configuration (quick, but slow and less accurate), or load AWStats' geoip2_country plugin with a MaxMind GeoLite2 country database (accurate, and the better choice). Both are server admin (root) tasks; on shared hosting, ask your provider.
The old geoip plugin that many guides still describe needs MaxMind's legacy GeoIP database. According to DirectAdmin, that method is outdated because MaxMind dropped GeoIP v1 support in 2019, so use geoip2_country instead.
Where DirectAdmin keeps the AWStats configuration
- Per domain:
/home/USERNAME/domains/example.com/awstats/.data/awstats.example.com.conf - Template for new domains:
/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf. According to DirectAdmin, it is copied to a domain on its first AWStats run, so editing it does not change existing domains.
Option 1: country stats from reverse DNS
In the domain's configuration file, set:
DNSLookup=1
AWStats then guesses the country from each visitor's hostname. DirectAdmin warns that this will likely slow down stats processing a lot, and it only works for IPs that have a reverse DNS (PTR) record, so many visitors still show as unknown.
Option 2: the GeoIP2 country plugin (recommended)
- Install the Perl module the plugin needs,
GeoIP2::Database::Reader. On AlmaLinux or Rocky Linux, CPAN is the usual way:cpan -i GeoIP2::Database::Reader
On Debian or Ubuntu, the package is available:apt install libgeoip2-perl
- Create a free MaxMind account and download the GeoLite2 Country database in
.mmdbformat. MaxMind requires an account and licence key for GeoLite2 downloads, and you should update the file regularly (MaxMind'sgeoipupdatetool can do it). - Place the file in a fixed path, for example
/usr/local/share/GeoIP/GeoLite2-Country.mmdb. - Open the domain's AWStats configuration file and add this line, or remove the
#in front of the existing one:LoadPlugin="geoip2_country /usr/local/share/GeoIP/GeoLite2-Country.mmdb"
- Keep
DNSLookupoff (DNSLookup=0) so the update stays fast. The plugin works from the IP address alone. - To use the plugin for domains created later, add the same line to
awstats.model.conftoo. - Wait for the next statistics run, or rebuild the account's stats now by queuing a tally (replace
USERNAME):echo "action=tally&value=USERNAME&type=user" >> /usr/local/directadmin/data/task.queue
Check that the plugin loads
Check the Perl module first:
perl -MGeoIP2::Database::Reader -e 'print "GeoIP2 module OK\n"'
Output:
GeoIP2 module OK
If it prints Can't locate GeoIP2/Database/Reader.pm, the module is not installed for the Perl that AWStats uses. In our lab test with AWStats 7.9, a wrong .mmdb path did not stop the update with an error, so if the country table stays empty, check the path and the file permissions first.
Related
- Switch on AWStats in DirectAdmin: I want to have the DirectAdmin version of Awstats
- What each AWStats report means: Awstats Stats Explained
- Webalizer instead: How to Customise Webalizer Output in DirectAdmin
Official documentation: DirectAdmin, website statistics.