MaxMind provides an optional C extension that is a drop-in replacement for
MaxMind\Db\Reader. This will speed up the location lookups for GeoIp2 PHP provider enormously and is recommended for high traffic instances.
Activate the GeoIp2 Plugin in Matomo
Check that the GeoIp2 plugin is activated in Matomo. To activate the plugin, go to the “Settings > Plugins” page and click “Activate” next to the GeoIp2 plugin.
The PHP extension requires the C library libmaxminddb for reading MaxmindDB files. To install the library you need to download it’s latest tar ball and extract it, or clone their git repository.
git clone --recursive https://github.com/maxmind/libmaxminddb
Note: When cloning from git, run
./bootstrap from the libmaxminddb directory and then run the commands below.
To install it, run the following commands:
$ ./configure $ make $ sudo make install $ sudo ldconfig
You can find more details about installing the library in their READM
After successfully installing libmaxmindb, you need to download or checkout MaxMind-DB-Reader-php.
Then run the following commands from the top-level directory of this distribution:
cd ext phpize ./configure make sudo make install
You then must load your extension. The recommend method is to add the following to your php.ini file:
Now restart the webserver and the GeoIP 2 PHP provider should mention if the extension is loaded in Matomo (Piwik) > Settings > Geolocation.
Note: You may need to install the PHP development package on your OS such as php5-dev for Debian-based systems or php-devel for RedHat/Fedora-based ones.