How to Install Matomo Web Analytics Tool on Ubuntu 18.04

Matomo is an open-source web analytics platform, which provides you a complete control over your data. It is a great alternative to Google Analytics. It helps you to gather all the significant information about the users of your website.

You can track key performance indicators, including goal conversion rates and the number of visits, efficiently. In this article, you will find the step by step guideline for installing it on Ubuntu 18.04. But before that, let’s take a look at the requirements.

Requirements for Installing Matomo on Ubuntu 18.04

  • PHP 5.5.9 or greater version
  • MySQL 5.5 or greater version
  • MariaDB (alternative to MySQL)
  • Web servers, like Apache, Nginx, IIS etc.
  • PHP extension pdo and pdo_mysql, or the MySQL extension

Installing Matomo on Ubuntu 18.04

  1. Install PHP with all the required extension
     by using the following command:
    sudo apt-get install php php-fpm php-curl php-gd php-cli php-mysql php-xmlphp-mbstring

  2. Now, you have to install the database. As stated earlier, you have two options – MySQL or MariaDB.
    Here, we will be using the latter one. Follow the steps mentioned here for installing MariaDB.
  3. Sign into MySQL shell as root user.
    $ mysql -u root -p

  4. Create a database and user. Grant all privileges.
    Step 4: Create a database and user. Grant all privileges.
GRANT ALL PRIVILEGESON matomo.* TO'matomo'@'localhost'IDENTIFIEDBY"StrongPassword";

  1. Get the newest version of Matomo.
$ wget

  1. Unzip the downloaded file.

$ unzip

  1. Move piwik directory to /srv/.

$ sudo mv piwik /srv/matomo/

  1. Get nginx.

$ sudo apt-get install nginx

  1. Create nginx configuration file for the analytics platform.

$ sudo vim /etc/nginx/conf.d/matomo.conf

  1. Insert the following lines in the configuration file:

server {
    root /srv/matomo;
    index  index.php index.html;
    access_log  /var/log/nginx/matomo_access.log;
    error_log   /var/log/nginx/matomo_error.log;


    location / {
        try_files$uri /index.php?$query_string;

    location~ .php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass             unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_param            SCRIPT_FILENAME $document_root$fastcgi_script_name;

Make sure that the values of server_name and fastcgi_pass match with your existing settings.

  1. Now, change the ownership of Matomo directory.

$ sudo chown -R www-data:www-data /srv/matomo/

  1. Restart and enable nginx.

$ sudo systemctl restart nginx
$ sudo systemctl enable nginx

  1. Open your favorite browser. Go to
  2. You will see a welcome page. Click “Next.”

How to Install Matomo Web Analytics Tool on Ubuntu 18.04

  1. You will see a System Check page. Make sure that all the system checks have been passed. Click “Next.”
  2. The Database Setup page will appear. Use the following credentials:

Database Server :
Login: matomo
Password: <StrongPassword>
Database Name: matomo
Adapter: PDO/MYSQL

  1. If you have used the credentials correctly, you will see a success message for creating tables. Click “Next.”

How to Install Matomo Web Analytics Tool on Ubuntu 18.04

  1. Now, you have to create a superuser. Insert your desired username, password, and email ID.
  2. Next, you have to set up your website. Insert your website name, URL and time zone. You can either enable or disable e-commerce option.
  3. You will see a congratulations page. Basically, it tells you that the installation of Matomo has been completed successfully.

You will be provided with a JavaScript tracking code. You should copy and save it for later use. Next, you will see a login page. Enter your username and password correctly to get into Matomo.


In this article, you have learned the steps for installing Matomo on Ubuntu 18.04 web hosting. Now, you can perform a wide range of functions, including tracking goals and making e-commerce orders.

Check out these top 3 Linux hosting services

Was this article helpful?