How to Install Matomo Web Analytics on Ubuntu 20.04

how to install matomo web analytics on ubuntu 20.04

Matomo (formerly known as Piwik) is a free and open-source web analytics application developed in PHP to be the ultimate alternative to Google Analytics. Matomo can be used to track online visits to one or more websites and displays reports on these visits for analysis.

In this tutorial, we will show you how to install Matomo Web Analytics on your Ubuntu 20.04 VPS.


  • Ubuntu 20.04 VPS
  • SSH root access or a regular system user with sudo privileges

Step 1. Log in via SSH and update the system

Log in to your Ubuntu 20.04 VPS with SSH as a root user:

ssh root@IP_Address -p Port_number

Replace “IP_Address” and “Port_Number” with your server’s IP address and SSH port.

Now, run the following command to update all installed packages to the latest available version.

apt update && sudo apt upgrade

Step 2: Install Apache Webserver

Execute the following command to install Apache webserver:

apt install apache2

To start Apache and to enable it to auto-start on server boot, run these commands:

systemctl start apache2
systemctl enable apache2

Step 3: Install PHP with required extensions

To install PHP and the required PHP extensions, run the following command:

apt install php php-cli libapache2-mod-php php-common php-curl php-gd php-mbstring php-mysql php-xml php-intl php-zip

Step 4: Install MariaDB and create a database for Matomo

Matomo needs a database server, and it can be installed running the following command:

apt install mariadb-server

Once the MariaDB server has been installed, log in to the MariaDB shell as root user and create a database and user for Matomo:

mysql -u root -p
MariaDB [(none)]> CREATE DATABASE matomodb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON matomodb.* TO 'matomouser'@'localhost' IDENTIFIED BY 'Passw0rd';
MariaDB [(none)]> EXIT;

Don’t forget to replace ‘Passw0rd’ with an actual strong password.

Step 5: Download Matomo on Ubuntu 20.04

Download the latest version of Matomo from the official website on your server:


Once downloaded, unzip the downloaded file with the following command:

unzip -d /var/www/html/

Then change the ownership of Matomo to www-data:

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

Step 6: Create an Apache configuration file

To create a new configuration file for Matomo, we can create a new Apache configuration file:

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

A basic Apache configuration file looks similar to this:

 <VirtualHost *:80>
     DocumentRoot /var/www/html/matomo
     <Directory /var/www/html/matomo/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted

     ErrorLog ${APACHE_LOG_DIR}/matomo_error.log
     CustomLog ${APACHE_LOG_DIR}/matomo_access.log combined

Don’t forget to change the domain name next to ServerAdmin and ServerName ( in order to make it work with your unique registered domain name.

Save and close the file then activate the Matomo virtual host with the following command:

a2ensite matomo.conf

Restart the Apache service and you are ready:

systemctl restart apache2

Step 7. Install SSL certificate

In this step, we will enable SSL for Matomo by using a free Let’s Encrypt SSL certificate.

apt install python3-certbot-apache -y

Once, the Certbot is installed we are ready to install the certificate for the domain:

certbot --apache

After the successful installation the following similar message will be received:

- Congratulations! Your certificate and chain have been saved at:
Your key file has been saved at:

Step 8: Installing Matomo Using the Web Interface

To run the web installation wizard go to and you will be redirected to the Matomo welcome page. Click on the “Next” button:

install matomo web analytics on ubuntu 20.04

You will see a “System Check” page. If everything is marked with a green checkmark click on the “Next” button to proceed to the next step:

install matomo on ubuntu 20.04

You should get to the Database Setup page. Use database credentials configured earlier:

install matomo web analytics on ubuntu

The creation of the Tables should return the “Tables created with success!” message:

install matomo web analytics ubuntu 20.04

Next, you have to create a Super User. Provide username, password, and email address.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99

matomo web analytics on ubuntu 20.04

Now, provide the site name, website URL, and then, click on the Next button.

matomo web analytics on ubuntu

You should see the Tracking code for the Matomo site on the following page:

matomo analytics on ubuntu 20.04

Next, you should see that the Matomo installation has been completed. Click on the CONTINUE TO MATOMO button.

matomo on ubuntu 20.04

Now, you can log in to the Matomo administration back-end:

install matomo analytics on ubuntu 20.04

You should see the Matomo Dashboard and you can add more websites, check the stats, etc:

matomo web analytics ubuntu 20.04

That is it. The Matomo installation is now complete. Of course, you don’t have to do any of this if you use one of our Ubuntu Hosting services, in which case you can simply ask our expert Linux admins to install Matomo for you. They are available 24×7 and will take care of your request immediately.

PS.  If you liked this post on how to Install Matomo Web Analytics on Ubuntu 20.04, please share it with your friends on social networks or simply leave a reply. Thank you.

Leave a Comment