After setting up the initial Piwik install here is how you can set up the GeoIP location module set up to enable you to view visitor results from City and Country Location. Piwik can take advantage of Maxminds’ databases to track visitor IP address to City/Country location.
First you need to set up the PHP extension for GeoIP, download the Geo database and confirm it’s location and then auto update the database updates.
Installing GeoIP on PHP 7.1
If the PHO version you are using change the version number – such as 5.6 (if you are using PHP 5.6)
sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install libgeoip-dev sudo pecl7.1-sp install geoip-beta
Followed by some PHP config
sudo bash -c "echo extension=geoip.so > /etc/php7.1-sp/conf.d/geoip.ini" sudo service php7.1-fpm-sp restart
Point ServerPilots PHP Config to the Geo Database
.user.ini file in your apps webroot and add in the path to the database
geoip.custom_directory = "/pathtopiwikinstall/misc"
Set the Piwik GeoLocation Setting
In Piwik > Settings > System > GeoLocation – select the GeoIP (PECL) selection.
MaxMind GeoIP Databases
With the PHP & Piwik configuration complete now what is needed is to use the City databases which link IP addresses to City/Country, there are paid and free options available from Maxmind, download the GeoLite city database in binary format, rename it
GeoIPCity.dat and file in your /misc directory in the Piwik installation.
Confirm Piwik Can Access Database
This is done by seeing that the Piwik > Settings > System > GeoLocation settings can see where you are from !
Set Up Piwik to AutoUpdate the Database
The GeoLite City database is changed each month, Piwik can automatically download and use the latest version also in the Piwik > Settings > System > GeoLocation settings. It’ll prompt you with the correct URL to use.