Skip to main content

Matomo on CentOS 7

Installing Matomo

Matomo, formerly known as Piwik, is an open source web analytics application. It rivals Google Analytics and includes even more features and allows you to brand your brand and send out custom daily, weekly, and monthly reports to your clients.

First let’s start by ensuring your system is up-to-date and has the needed repositories.

yum -y install epel-release
yum -y install
yum clean all
yum -y update
reboot # if kernel updated

Install needed packages

yum -y install wget mariadb mariadb-server mysql httpd openssl mod_ssl php72u-json mod_php72u php72u-gd php72u-imap php72u-ldap php72u-odbc pear1u php72u-xml php72u-xmlrpc php72u-mbstring php72u-mysqlnd php72u-snmp php72u-soap php72u-tidy curl curl-devel mcrypt

Configure MySQL

systemctl restart mariadb.service   # Start MySQL service
mysql_secure_installation   # Set root password 
mysql -u root -p   # Enter root password

Add the database and user.

GRANT ALL PRIVILEGES ON matomodb.* TO 'matomouser'@'localhost' IDENTIFIED BY 'YourAwesomePassword' WITH GRANT OPTION;

Installing Matomo on CentOS 7.

cd /var/www

Unpack the Matomo archive to the document root directory on your server.

unzip -d /var/www/html/
mv /var/www/html/piwik/ /var/www/html/matomo/

Update owner on Matomo files and folders

chown -R apache:apache /var/www/html/matomo

Configure Apache
Create Apache virtual host for Matomo . First create ‘/etc/httpd/conf.d/vhosts.conf’ file

vim /etc/httpd/conf.d/vhosts.conf

IncludeOptional vhosts.d/*.conf

Create the virtual host.

mkdir /etc/httpd/vhosts.d/
vim /etc/httpd/vhosts.d/

Add the following to the new vhost config.

<VirtualHost YOUR_SERVER_IP:80>
DocumentRoot /var/www/html/matomo
ErrorLog "/var/log/httpd/"
CustomLog "/var/log/httpd/" combined

<Directory "/var/www/html/matomo/">
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride All
Require all granted

Start Apache

systemctl start httpd

Verify that Apache is running by checking the status of the service:

systemctl status httpd

Install certbot to handle SSL

yum install -y mod_ssl python-certbot-apache

Run Certbot to secure the Apache site

certbot --apache -d

Enable services and reboot the server and make sure it works.

systemctl enable httpd mariadb

Browse to and follow the Matomo setup steps.

For details see

Installing libmaxminddb

Install git and PHP development libraries.

yum -y install php72u-devel git automake autoconf libtool

To install the library you need to download it’s latest tar ball and extract it, or clone their git repository

git clone --recursive

When cloning from git, run ./bootstrap from the libmaxminddb directory and then run the commands.

sudo make install
sudo ldconfig

You can find more details about installing the library in their README

Installing Extension

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
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.

If after installing, you receive an error that is missing you may need to add the lib directory in your prefix to your library path. On most Linux distributions when using the default prefix (/usr/local), you can do this by running the following commands:

echo /usr/local/lib  >> /etc/

Download the GeoIP database and copy it to Matomo’s path/to/matomo/misc/ subdirectory.

cp GeoLite2-City_20190312/GeoLite2-City.mmdb /path/to/matomo/misc/