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.
CREATEDATABASE matomo;
GRANT ALL PRIVILEGESON matomo.* TO'matomo'@'localhost'IDENTIFIEDBY"StrongPassword";
FLUSHPRIVILEGES;
Quit

  1. Get the newest version of Matomo.
$ wget https://builds.piwik.org/piwik.zip

  1. Unzip the downloaded file.

$ unzip piwik.zip

  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 {
    listen80;
    root /srv/matomo;
    index  index.php index.html;
    access_log  /var/log/nginx/matomo_access.log;
    error_log   /var/log/nginx/matomo_error.log;
    server_name  stats.example.com www.stats.example.com;

    client_max_body_size100M;

    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 http://stats.example.com.
  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 : 127.0.0.1
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.

Conclusion:

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

HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
Kamatera
$4.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
Hostens
$2.00 /mo
Starting price
Visit Hostens
Rating based on expert review
  • User Friendly
    4.5
  • Support
    3.8
  • Features
    4.3
  • Reliability
    4.5
  • Pricing
    4.8

How to Create a Non-root User on Your Ubuntu 18.04 VPS or Dedicated Server

This guide shows you how to create a user on your Ubuntu 18.04 virtual server.
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Install a Self-Signed SSL Certificate on Your Ubuntu 18.04 VPS or Dedicated Server

This how-to article will teach you how to create a self-signed SSL certificate o
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Set Up Cron Jobs on Your Ubuntu 18.04 Dedicated Server or VPS

This guide shows webmasters and administrators how to set up cron jobs on your U
3 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install WordPress on Your Ubuntu 22.04 VPS or Dedicated Server

This tutorial will show you how to install WordPress on your Ubuntu 22.04 virtua
3 min read
Idan Cohen
Idan Cohen
Marketing Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.