Matamo (formerly Piwik) is a free and open source web analytics application developed in PHP to be the ultimate alternative to Google Analytics, with full control over your data. Matomo can be used for a site with a few visits per day or websites that receive many millions of visits per day to track Key Performance Indicators such as visits, goal conversion rates, downloads, keywords, and many more.

My previous related article was How to Install Fathom website analytics tool on Ubuntu / CentOS / Arch Linux

Matamo gives you a detailed user-centric insight on website actions, both for the direct visits to the website or access through a mobile application. You can extend and customize the application using its API’s and detailed user documentation. Install Matomo today and get to learn about your users’ behavior – where they come from, what they are doing and where they are going.

See a full list of Matamo Dashboards

Install Matomo (Piwik) Web Analytics Tool on Ubuntu 20.04|18.04|16.04

The installation of Matomo ( formerly Piwik) on Ubuntu is covered in this section. The process is straightforward and should be easy to follow.

To run Matomo (Piwik) your host server need to have a couple of things:

  • A web server such as Apache, Nginx, IIS, etc.
  • PHP version 5.5.9 or greater
  • MySQL version 5.5 or greater, or MariaDB
  • PHP extension pdo and pdo_mysql, or the mysqli extension.

Step 1: Install PHP 7 with required Extensions

Run below commands to install PHP 7 on your Ubuntu:

sudo apt-get update
sudo apt-get install php php-fpm php-curl php-gd php-cli php-mysql php-xml php-mbstring

Step 2: Install MySQL / MariaDB

As mentioned earlier, Matomo needs a database server, which can be MySQL or MariaDB.

sudo apt-get -y install mariadb-server

After installing a database server, proceed to create a user used by Matomo

Login to MySQL shell as root user

$ mysql -u root -p

Create a database and user with access privileges

GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost' IDENTIFIED BY "StrongPassword";

Step 2: Download Matomo / Piwik

Download the latest release of Matomo/Piwik using wget


Uncompress the package


Move piwik directory to /srv/

sudo mv piwik /srv/matomo/

Step 2: Install Nginx and configure Nginx

Download and install nginx

sudo apt-get install nginx

Create nginx configuration file for Matomo

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

Add the following contents:

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

    client_max_body_size 100M;

    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;

Change server_name and fastcgi_pass  values to match your correct settings.

Change Matomo directory ownership

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

Start nginx and ensure it is set to start on boot

sudo systemctl restart nginx
sudo systemctl enable nginx

Step 3: Setup Matomo / Piwik

Access Setup web page by opening the link on your browser. You should be greeted with a welcome page. Click “Next”

install matomo web analytics ubuntu 18.04 01 min

Ensure all system checks are passed, then click the “Next” button

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

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

Creation of the Tables should return a success.

install matomo web analytics ubuntu 18.04 database min

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

install matomo web analytics ubuntu 18.04 setup superuser successful min

Setup a Website by providing:

  • Website name
  • Website URL
  • Website time zone
  • Enable/Disable Ecommerce
install matomo web analytics ubuntu 18.04 successful installation min

Copy and save generated JavaScript Tracking Code. A login page should appear, provide username and password to get in.

install matomo web analytics ubuntu dashboard signin min

If you want to do more than track page views, please check out the Matomo Javascript Tracking documentation for the list of available functions. Using these functions you can track goals, custom variables, e-commerce orders, abandoned carts and more.

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here