Content
- page: Overview of basic terms and preparation for Matomo hosting
- page: Download and install Matomo
- page: Placing tracking code on WordPress pages
- page: Placing tracking code on Drupal pages
- page: Placing and customizing tracking code on custom pages
- page: Make important settings after installation
- page: Installation of GeoIP 2 (PHP) based geolocation system
- page: Matomo migration of a complete system to PHP-FPM based server API operation
7. page content
Continuation
Az previous page we have done the Matomo (Piwik) After installing the system, we will continue to install and configure the geolocation tools so that we can see in our statistics which cities our visitors come from.
Other necessary settings
Set geolocation
Our last task, setting the geolocation, remained. As Matomo suggests on the System Audit page, the PHP based GeoIP 2 solution. There are several methods (e.g. Apache module), but it's the easiest to install.
The geolocation databases are available in both paid and free versions at MaxMind ensure. You will need one to use it libmaxminddb library, called C, and one MaxMind-DB-Reader-php PHP extension.
Basic conditions for compiling source code
The following sections contain source code translations for which gcc and the make commands are required. And these are the gcc and the build-essential packages included. Of the servers I have created, only Debian 8 (Jessie) LAMP Server does not include them, so if you are installing Matomo on such a server, - a luggage racks After updating, install them as follows:
apt-get update
apt-get -y upgrade
apt-get -y install gcc build-essential
If you are using another system for which we are unsure of the existence of these packages, you can check below grep command:
dpkg -l | grep "gcc\|build-essential"
If you list here gcc and the build-essential package, you can skip to the next section. If not, install them using the commands above.
I've checked the servers, and after installing any missing packages, translation is now working everywhere.
Install the libmaxminddb library
Using the libmaxminddb library, our system will be able to read the files in the MaxMind database. The source code for the library can be downloaded from the GitHub site. Direct git it could also be accessed by cloning, but using a source in a live Git repo can lead to addiction issues that need to be improvised so there is no exact recipe for them. To avoid this, we prefer to download the finished tarball source package. To do this, first find the latest version at the top of the link below:
https://github.com/maxmind/libmaxminddb/releases
Then below the description libmaxminddb-xyztar.gz copy the link to the file. This is exactly what I have:
https://github.com/maxmind/libmaxminddb/releases/download/1.3.2/libmaxminddb-1.3.2.tar.gz
Then log in as root, continue with the procedure, starting with / tmp and downloading tarball:
cd /tmp
wget https://github.com/maxmind/libmaxminddb/releases/download/1.3.2/libmaxminddb-1.3.2.tar.gz
Unzip the downloaded archive file to tar and then go to the directory you created:
tar -xvzf libmaxminddb-1.3.2.tar.gz
cd libmaxminddb-1.3.2
Then, compile the source code using the following commands:
./configure
make
make check
The last command can be used to check that the translation is correct. If all is well, we should see such an output:
Finally, install the compiled package and run it ldconfig command to rebuild the cache:
make install
ldconfig
This is done by compiling and installing the libmaxminddb C library.
Install MaxMind-DB-Reader-php PHP Plugin
You will need the phpize which can be found in the developer package of our PHP system. First we check the (default) PHP version of their system:
php --version
Download the appropriate PHP development package based on our version:
- For PHP 5: php5-dev
- For PHP 7.0.x: php7.0-dev
- For PHP 7.1.x: php7.1-dev
- For PHP 7.2.x: php7.2-dev
- etc. ...
I have this Debian 9 (Stretch) on the perfect server PHP 7.0 is the default, so I'm using this now:
apt-get -y install php7.0-dev
Then go to the / tmp directory and download MaxMind-DB-Reader-php PHP plugin zip version of the From GitHub:
cd /tmp
wget https://github.com/maxmind/MaxMind-DB-Reader-php/archive/master.zip
Unzip and enter the ext / subdirectory under the created directory:
unzip master.zip
cd MaxMind-DB-Reader-php-master/ext
Here, run the phpize command (as root):
phpize
Normally it gives a similar output (depending on our PHP version):
Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012
Then configure, compile the source, and install it (also as root):
./configure
make
make install
At the end it gives one of the following output:
Installing shared extensions: /usr/lib/php/20151012/
Open the php.ini file (for PHP 7.x: /etc/php/7.x/apache2/php.ini For PHP5: /etc/php5/apache2/php.ini):
nano /etc/php/7.0/apache2/php.ini
And add the following line to the end:
extension=maxminddb.so
Save and restart Apache:
systemctl restart apache2.service
Activate Matomo GeoIP 2 plugin
Once you have got here, go back to the Matomo interface and click on the upper right gear and go to the left menu System group Geolocation of options:
Here you can see that the default mode is active and below GeoIP 2 (Php) part is still gray and below it is "not installed". Here, scroll down to the bottom of the page to find a "GeoIP Databases" panel:
Here, if you did not purchase the paid database but would like to use the free one, click on the green button on the left and you will automatically download the free geolocation database from MaxMind.
Once the strip is complete, a 61 Mb GeoLite2-City.mmdb file is downloaded and stored in the following directory:
<matomo telepítési könyvtára>/misc/
Of course, this is no longer an issue, but I will write if it is needed.
We will then return to the top of the same page where it is already green in GeoIP 2 (Php) to indicate that it is installed:
Here, select GeoIP 2 (Php) and save the setting by clicking the save button at the bottom of this panel.
If you scroll down to the bottom of the page again, you will see the auto-update sections, where the download URL is already set, and Matomo will download the latest version every month (updated monthly, by the way).
We don't have to deal with this anymore, we are ready with the geolocation settings.
Let's not go anywhere yet, because it is last page we reset the whole system a PHP-FPM based operation.
- Encyclopedia - Matomo (Piwik) web analytics
- How to upgrade our Matomo (formerly Piwik) web analytics system to version 4.x.
- Matomo.org
- Matomo.org - How do I install the PHP extension for GeoiIP 2?
- What should we do if our Matomo web analytics system generates "AH01630: client denied by server configuration" type Apache errors that causes Fail2Ban to block our IP address?
- Server monitoring with Munin on Debian 9 (Stretch) and Debian 10 (Buster)
Navigation
- To post registration and login required
- 88 views