tst installation matomo complete setup guide for ubuntu

Author

Reads 1.3K

Close-up of hands typing on a laptop displaying data analysis charts, perfect for business contexts.
Credit: pexels.com, Close-up of hands typing on a laptop displaying data analysis charts, perfect for business contexts.

Matomo is a fantastic open-source analytics platform that can be easily installed on Ubuntu. To get started, you'll need to download the Matomo installation package from the official Matomo website.

The first step in the installation process is to create a new database for Matomo. This is done by running the following SQL command: CREATE DATABASE matomo;.

You'll also need to create a new user for the Matomo database, which is done by running the following SQL command: CREATE USER 'matomo_user'@'localhost' IDENTIFIED BY 'matomo_password';.

To complete the database setup, you'll need to grant the new user permissions to access the database: GRANT ALL PRIVILEGES ON matomo.* TO 'matomo_user'@'localhost';.

Now that the database is set up, you can proceed with the Matomo installation.

System Requirements

To install Matomo, you'll need a suitable web server. Apache, Nginx, and IIS are all supported options.

You'll also need a PHP version of at least 5.5.9 to get started.

Credit: youtube.com, Matomo On-Premise installation overview

PHP extensions like pdo, pdo_mysql, or mysqli are necessary for Matomo to function properly.

For database management, MySQL version 5.5 or MariaDB is the minimum requirement.

To summarize, here are the supported web servers and PHP versions:

  • Web server: Apache, Nginx, IIS, etc
  • PHP version: >=5.5.9
  • PHP extension: pdo, pdo_mysql, or mysqli
  • Database: MySQL version >=5.5 or MariaDB

Installation Process

To install Matomo, start by downloading the Matomo files using the command `wget https://builds.matomo.org/matomo.zip`. This will begin the process of setting up Matomo on your server.

The Matomo files need to be copied to the DocumentRoot, which can be done using the command `cp -Rv matomo/* /var/www/matomo.defnex.com`. This will ensure that the files are in the correct location for the installation to proceed.

The ownership of the Matomo files also needs to be set to `www-data:www-data` using the command `chown -R www-data:www-data /var/www/matomo.defnex.com`. This will give the necessary permissions for the installation to complete.

Here are the steps to complete the Matomo installation:

  1. Enter the database name, username, and password that was created.
  2. Copy the tracking code that must be installed on the website.
  3. Click “Next” to complete the installation process.

Install and Enable PHP Modules

Installing PHP modules is a crucial step in the Matomo installation process. You'll need to install and enable the required PHP modules to proceed.

Apache users will need to reload the web server to make the PHP modules work. Nginx users, on the other hand, don't need to reload anything.

After installing and enabling the PHP modules, you'll be able to access the Matomo web-based install wizard at http://analytics.example.com.

Setting Up Cron Jobs for High-Traffic Websites

Credit: youtube.com, How to setup Cron Jobs in cPanel hosting | Configure Cron job Easily within 2 mins [2024]

If your website has thousands of page views per day, it's necessary to set up a cron job to auto-archive Matomo reports.

To create the Cron job file, use the following command.

Standard output will be sent to /dev/null and standard error will be sent to your email address.

Save and close the file, then add the following lines to it.

This Cron job will run every hour at 5 minutes past.

Installation Steps

To install Matomo, you'll need to download the Matomo files using the command `wget https://builds.matomo.org/matomo.zip`. Copy the Matomo files to your DocumentRoot directory using the command `cp -Rv matomo/*/var/www/matomo.defnex.com`.

The Matomo installation process will then check your server environment and requirements. Ensure that all requirements are met and properly configured.

You'll need to set up the MariaDB database details by providing the correct database username and password. Matomo will automatically create the necessary database tables if the database details are correct.

Credit: youtube.com, How to install Matomo Analytics - Cloud hosted version

Here are the steps to complete the installation:

  1. Open your web browser and visit your Matomo domain name (e.g., https://analytics.example.io).
  2. On the welcome page, click “Next” to start the installation process.
  3. Set up the MariaDB database details by providing the correct database username and password.
  4. Create a new admin user for Matomo by providing a strong password.
  5. Configure the first website tracking by entering the domain name and selecting the timezone.

After completing the installation, click “CONTINUE TO MATOMO” to access the Matomo administration interface.

Virtual Host Setup and Security

To set up a virtual host for Matomo, you need to create a new Apache2 virtual host configuration file. This file will map your domain name to the Matomo installation directory.

Follow these steps to configure the virtual host:

  1. Create a new Apache2 virtual host configuration file.
  2. Add the following configuration to the file, replacing analytics.example.io with your desired domain name:
  3. Save the file and exit the text editor.
  4. Enable the virtual host configuration by running the following command:
  5. Restart the Apache2 service to apply the changes:

With the virtual host configured, you can access Matomo through your domain name, but you'll still need to secure the installation with SSL/TLS certificates.

Virtual Host Setup

To set up a virtual host for Matomo, you need to create a new Apache2 virtual host configuration file. This will map the domain name to the Matomo installation directory.

You'll need to add a specific configuration to the file, replacing "analytics.example.io" with your desired domain name. This is a crucial step, as it will allow you to access Matomo through your domain name.

Credit: youtube.com, Apache Virtual Hosts

Save the file and exit the text editor once you've added the configuration. This will ensure that your changes are saved and ready to be applied.

Next, you'll need to enable the virtual host configuration by running a specific command. This will activate the virtual host and make it accessible through your domain name.

Finally, restart the Apache2 service to apply the changes. This will ensure that the virtual host is properly configured and ready to use.

Securing

Securing your virtual host is crucial for a safe and trustworthy online presence. To ensure secure communication between your users and the Matomo installation, you'll use Certbot and Let's Encrypt to generate SSL/TLS certificates.

Certbot and the Certbot plugin for Apache2 need to be installed first. This will allow you to obtain the necessary certificates for secure communication.

With SSL/TLS certificates in place, your Matomo installation is now accessible over a secure HTTPS connection.

Recommended read: Rclone Installation

Ubuntu Prerequisites

Credit: youtube.com, How to Install Matomo Analytics on Linux Local Server (2022)

To get started with installing Matomo on Ubuntu 22.04, you'll need a few things in place. You'll require a domain name, which I registered at NameCheap because of their low prices and free whois privacy protection for life.

A server with 1G RAM is sufficient to run Matomo, and I recommend checking out Kamatera VPS for a virtual private server. They offer a 30-day free trial and start at $4/month with 1GB RAM. Their high-performance KVM-based VPS is available in 9 data centers around the world, including the United States, Canada, UK, Germany, The Netherlands, Hong Kong, and Israel.

If you haven't already, set up a LAMP or LEMP stack on Ubuntu 22.04. You can find tutorials on how to do this by following these links: How to install LAMP stack on Ubuntu 22.04 serverHow to install LEMP stack on Ubuntu 22.04 server

You'll need to log in to your server via SSH to proceed with the installation.

A different take: Install Azure Cli Ubuntu

Advanced Configuration

Credit: youtube.com, Experimental: How to install Matomo / Piwik with Docker?

For a more advanced configuration of Matomo, you'll need to create a separate database for your tracker. This is done by setting the database type to "mysql" and specifying the database name in the config file.

You can also configure the tracker to use a different database user by setting the "database_user" parameter in the config file.

To enable the tracker to send emails, you'll need to set the "email_from" and "email_to" parameters in the config file.

The tracker can also be configured to use a proxy server by setting the "proxy_url" parameter in the config file.

You can also configure the tracker to use a different timezone by setting the "timezone" parameter in the config file.

Matomo uses a single table to store all its data, which is the "matomo" table. This table contains all the data collected by the tracker.

The tracker can also be configured to use SSL encryption by setting the "use_ssl" parameter to true in the config file.

Running Behind Cloudflare

Credit: youtube.com, Using Cloudflare Tunnels For Hosting & Certificates Without Exposing Ports On Your Firewall

If you're running Matomo behind Cloudflare CDN, it can only see the Cloudflare servers' IP address.

To show visitors' real IP addresses, you need to edit the Nginx main configuration file.

Add the set_real_ip_from directive to define trusted addresses, which in this case are Cloudflare IP addresses.

Cloudflare's current IP ranges can be checked for accuracy.

Save and close the file after adding the directive.

Then, reload Nginx for the changes to take effect.

Features and Benefits

Matomo offers a wide range of features that make it an excellent choice for web analytics. With over 30 reports categorized into four main analytics categories, you can get a comprehensive view of your website's performance.

Matomo's self-hosted edition is open-source and GPL v3+ licensed, allowing for flexibility and customization. The software can show top keywords and search engines, websites, and social media websites, giving you valuable insights into your website's traffic sources.

You can also track engagement metrics such as time on site, pages per visit, and repeated visits. Additionally, Matomo provides statistics email reports, web server log analytics, and the ability to track visitors who have disabled JavaScript.

Credit: youtube.com, Matomo Overview - Top Features, Pros & Cons, and Alternatives

Some of the key features include:

  • Top page URLs, page titles, user countries, providers, operating systems, browser market share, screen resolution, desktop VS mobile
  • Top campaigns, custom variables, top entry/exit pages, downloaded files
  • Classified into four main analytics report categories – Visitors, Actions, Referrers, Goals/Ecommerce
  • Statistics Email reports
  • Web server log analytics
  • Tools to comply with GDPR (such as cookie consent)
  • Install free or premium plugins to extend and expand the functionality of Matomo

Features

Matomo's feature set is incredibly robust, with a wide range of reports and analytics tools at your disposal.

Matomo's open-source edition is licensed under GPL v3+ and can show reports on top keywords and search engines, websites, and social media websites.

One of the standout features of Matomo is its ability to classify reports into four main analytics categories: Visitors, Actions, Referrers, and Goals/Ecommerce, with over 30 reports to explore.

You can also track visitors who have disabled JavaScript, which is a great feature for ensuring you're getting a complete picture of your website's traffic.

Matomo's easy-to-use web-based updater makes it simple to keep your analytics software up to date, and you can also use a command-line updater for added flexibility.

Here are some of the key reports you can generate with Matomo:

  • Top page URLs, page titles, user countries, providers, operating systems, browser market share, screen resolution, desktop VS mobile.
  • Engagement (time on site, pages per visit, repeated visits).
  • Top campaigns, custom variables, top entry/exit pages, downloaded files.

Matomo also offers tools to comply with GDPR, such as cookie consent, and allows you to install free or premium plugins to extend its functionality.

Self-Hosted Benefits

Credit: youtube.com, Cloud vs Self Hosted - Benefits and Risks

Self-hosted Matomo offers a range of benefits that make it an attractive option for businesses and individuals alike.

By hosting Matomo on your own server, you have full control over your data, which means it's stored only on your server and you can choose the country where the server is located.

One of the biggest advantages of self-hosted Matomo is that there are no data limits. You can store as much data as your server can handle, which is especially useful for businesses with high traffic or large datasets.

Self-hosted Matomo is also fully customizable and extensible, allowing you to tailor the software to your specific needs.

The extra security of self-hosted Matomo is also worth noting. With cross-site tracking cookies being blocked by Firefox, hosting your analytics software under your own domain name ensures that your tracking cookies won't be affected.

Here are some of the key benefits of self-hosted Matomo:

  • Full control of data
  • No data limits
  • Fully customizable and extensible
  • Protection from cross-site tracking cookie blocks

Margarita Champlin

Writer

Margarita Champlin is a seasoned writer with a passion for crafting informative and engaging content. With a keen eye for detail and a knack for simplifying complex topics, she has established herself as a go-to expert in the field of technology. Her writing has been featured in various publications, covering a range of topics, including Azure Monitoring.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.