Open source Software

How to install the Matomo web analytics platform on Ubuntu Server 20.04

Matomo logo
Image: Matomo

If you admin web sites, you know the way essential information evaluation will be. You may want to hold abreast of issues like guests, serps and key phrases used, languages spoken, pages favored, downloaded recordsdata and extra. That information will be an essential a part of rising and optimizing your websites and the content material you present.

SEE: Hiring Kit: JavaScript Developer (TechRepublic Premium)

One instrument for that is the open-source Matomo (previously Piwik). Not solely can Matomo hold you knowledgeable, but it surely additionally works with Google AdWords, Facebook Ads, Yahoo, and options cost-per-click evaluation, search advertising and a monitoring and reporting API.

If this seems like one thing you and/or your organization may gain advantage from, let’s get it put in.

What you’ll want

I’m going to show on Ubuntu Server 20.04, so that you’ll want a working occasion of that platform, together with a person account that has sudo privileges.

Ready? Let’s do that.

How to install the dependencies

The very first thing we’ll do is install the mandatory dependencies. Log into your Ubuntu occasion and install these packages with the command:

sudo apt-get install apache2 mariadb-server php libapache2-mod-php php-cli php-fpm php-fpm php-json php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath curl unzip -y

Once that set up completes, you’re prepared to maintain the database.

How to create the database

Before we create the database, let’s begin and allow MariaDB with:

sudo systemctl allow --now mariadb

Next, we want to safe MariaDB. Issue the command:

sudo secure_mysql_installation

Create a brand new password for the admin person after which reply ‘y’ for the remaining questions.

Log in to the MariaDB console with:

sudo mysql

Create the database with:


Create a brand new person with:

MariaDB [(none)]> CREATE USER 'matomo'@'localhost' IDENTIFIED BY 'PASSWORD';

Where PASSWORD is a powerful/distinctive password.

Grant the mandatory privileges to the person with:

GRANT ALL ON matomodb.* TO 'matomo'@'localhost' WITH GRANT OPTION;

Flush all privileges and exit the database console with:



How to obtain and unpack Matomo

Download the newest model of Matomo with the command:


Unpack the file with:


Move the newly created listing into the Apache doc root with:

sudo mv matomo /var/www/html/

Change the permissions and possession with:

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

sudo chmod -R 755 /var/www/html/matomo

How to configure Apache

We now flip to the configuration of Apache. Create a brand new .conf file with:

sudo nano /and many others/apache2/sites-available/matomo.conf

In that file, paste the following (modifying as wanted):

<VirtualHost *:80>



DocumentRoot /var/www/html/matomo/

<Directory /var/www/html/matomo>

DirectoryIndex index.php

Options FollowSymLinks

AllowOverride All

Require all granted


<Files "console">

Options None

Require all denied


<Directory /var/www/html/matomo/misc/person>

Options None

Require all granted


<Directory /var/www/html/matomo/misc>

Options None

Require all denied


<Directory /var/www/html/matomo/vendor>

Options None

Require all denied


ErrorLog ${APACHE_LOG_DIR}/matomo_error.log

CustomizedLog ${APACHE_LOG_DIR}/matomo_access.log mixed


Save and shut the file.

Enable the website with:

sudo a2ensite matomo.conf

Enable the rewrite module with:

sudo a2enmod rewrite

Restart Apache with:

sudo systemctl restart apache2

How to end the set up

Open a web browser and level it to http://SERVER/matomo. You will probably be greeted with the Matomo set up wizard (Figure A).

Figure A

The Matomo installation wizard is simple to complete.
The Matomo set up wizard is straightforward to full.

Click NEXT and the system verify will full. Scroll to the backside and click on NEXT. In the ensuing window (Figure B), fill out the mandatory info for the database. The login is matomo, the database title is matomodb, and the password is what you set in the MariaDB console. Click NEXT when completed.

Figure B

Setting the database parameters for Matomo.
Setting the database parameters for Matomo.

Once the tables are created, click on Next and also you’ll then be prompted to create a superuser to function the website administrator (Figure C).

Figure C

Creating a superuser for Matomo administration purposes.
Creating a superuser for Matomo administration functions.

Click Next and, in the subsequent window (Figure D), you’ll be prompted to arrange an internet site to analyze.

Figure D

Setting up your first site to be analyzed by Matomo.
Setting up your first website to be analyzed by Matomo.

Click Next and also you’ll then be prompted to add the mandatory JavaScript monitoring code to your web site. You’ll want to add the script earlier than the closing </head> tag on these web pages you need to be analyzed. The monitoring code web page in the wizard provides you loads of directions for doing this. The course of will range, relying on how your web sites had been constructed and who hosts the websites.

Before you click on NEXT, be sure to click on EMAIL THESE INSTRUCTIONS (Figure E) so you could have a reference copy for once you really begin including the monitoring code to pages.

Figure E

The tracking code instructions are pretty clear but will vary based on how your sites were built.
The monitoring code directions are fairly clear however will range primarily based on how your websites had been constructed.

Click Next after which click on CONTINUE TO MATOMO to lastly attain the precise website, the place you’ll be prompted to log in with the admin account you created. You’ll then be offered with much more directions on how to get the monitoring code added to your websites.

And that’s all there may be to getting the Matomo web evaluation platform put in. After this platform is up and working, you’ll in all probability spend extra time including monitoring code to websites than you probably did putting in the platform. But if information is essential to you and your enterprise, the effort will repay.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the newest tech recommendation for enterprise professionals from Jack Wallen.


Leave a Reply

Your email address will not be published.Required fields are marked *