Error with GeoIP/2

I’m using the latest version of HestiaCP with Apache + Nginx - Ubuntu 22

I first tried installing GeoIP, using:

/usr/local/hestia/install/upgrade/manual/install_awstats_geoip.sh

But I get the error when accessing awstats:

Error: Plugin init for plugin ‘geoip’ failed with return code: Error opening /usr/share/GeoIP/GeoIP.dat at (eval 8) line 5008, line 717. (A module required by plugin might be missing).

Setup (‘/etc/awstats/conf’ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs’ directory).

Back snapshot, and I installed GeoIP2:

/usr/local/hestia/install/upgrade/manual/install_awstats_geoip2.sh

But I get the message:

Error: Plugin load for plugin ‘geoip2_country’ failed with return code: Error: Can’t locate GeoIP2/Database/Reader.pm in @INC (you may need to install the GeoIP2::Database::Reader module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.34.0 /usr/local/share/perl/5.34.0 /usr/lib/x86_64-linux-gnu/perl5/5.34 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.34 /usr/share/perl/5.34 /usr/local/lib/site_perl /usr/share/awstats/lib /usr/share/awstats/plugins) at (eval 29) line 1. Error: Need Perl module GeoIP2::Database::Reader

Setup (‘/etc/awstats/conf’ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs’ directory).

In both installations, I received no error!

What to do?

Might not be relevant, but geoip has been retired, and you have to use GeoIP2 these days.
And to use GeoIP2, you have to get an API key (free).

Its not too hard to set up manually, so maybe try that rather than using the script. I think you just install geoipupdate and edit the config file in /etc/, adding the API key.
Then you need to install mmdb-bin so that programs can look up the IP (name may vary depending on distro). You can check its all working with
mmdblookup 1.2.3.4
from the command line

It doesn’t seem to be “just” an API error, I think the script is missing a dependency process.

Does anyone have a how-to to make it work on Hestia?

I found the solution, here’s a “mini how to”

mkdir /usr/share/GeoIP

cpan -i YAML
cpan -i Geo::IP Geo::IP::PurePerl
cpan -i Net::IP Net::DNS Net::XWhois
cpan -i GeoIP2::Database::Reader

wget https://cdn.jsdelivr.net/npm/[email protected]/GeoLite2-Country.mmdb.gz
gzip -d GeoLite2-Country.mmdb.gz
mv GeoLite2-Country.mmdb /usr/share/GeoIP/

ln -s /etc/awstats/awstats.conf /etc/awstats/conf

bash /usr/local/hestia/install/upgrade/manual/install_awstats_geoip2.sh

v-update-sys-queue webstats

After exactly that, information by country started to appear correctly!