How to Install Matomo on Ubuntu 18.04

r00t June 6, 2018

Install Matomo on Ubuntu 18.04

In this tutorial we are going to learn how to install Matomo on Ubuntu 18.04. We will also install and configure its prerequisites. Matomo (previously known as Piwik) is a popular and free analytics platform currently used by individuals, companies and governments all around the world. When you would like to take the whole control of your own website analytics and data without using third party alternatives, like Google Analytics, subsequently Matomo is a superb place to get started.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 Bionic Beaver minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Matomo on Ubuntu 18.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Installing LAMP on Ubuntu 18.04.

You should check out this LAMP stack install tutorial for Ubuntu 18.04, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that TextPattern CMS relies on:

apt-get install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip

Step 3. Installing Matomo on Ubuntu 18.04.

First, download Matomo from the official website and extract it to the /var/www/matomo directory on the server:

wget https://builds.matomo.org/piwik.zip -O matomo.zip
unzip matomo.zip -d /var/www/

Now just set the right permissions for the folders:

chown -R www-data:www-data /var/www/matomo

Step 4. Create a database for Matomo.

Next, we need to create a database for the Matomo installation:

mysql -uroot -p

Run the following command to create a database for Matomo:

MariaDB [(none)]> CREATE DATABASE matomo;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON matomo.* to 'matomo'@'localhost' IDENTIFIED BY 'y0ur_Pa55w0rd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

Step 5. Configure Apache web server for Matomo.

For this you can take the default config as a template:

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/matomo.conf

Now edit the currently created Config as follows:

nano /etc/apache2/sites-available/matomo.conf

Modify the virtual host file for your Matomo site to resemble the example below:

<VirtualHost *:80>
 ServerAdmin admin@example.com
 DocumentRoot /var/www/matomo
 ServerName example.com
 ServerAlias www.example.com

<Directory /var/www/matomo/>
 Options FollowSymlinks
 AllowOverride All
 Require all granted
 </Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Finally, reload the web server as suggested, for the changes to take effect:

a2ensite matomo.conf
a2enmod rewrite
systemctl restart apache2.service

Step 6. Accessing Matomo.

Now you can access the Matomo web install wizard in your browser by entering the domain name or http://yourdomain/matomo to continue your Matomo installation.

Install Matomo on Ubuntu 18.04

Congratulation’s! You have successfully install and configured Matomo on your Ubuntu 18.04 server. Thanks for using this tutorial installing Matomo analytics platform on Ubuntu 18.04 LTS (Bionic Beaver) system.

The Tags:

Leave a Comment

Comments are closed.