Contact Info

Atlas Cloud LLC 600 Cleveland Street Suite 348 Clearwater, FL 33755 USA

support@dedirock.com

Client Area
Recommended Services
Supported Scripts
WordPress
Hubspot
Joomla
Drupal
Wix
Shopify
Magento
Typeo3

Matomo (formerly known as Piwik) is a powerful open-source analytics platform that provides valuable insights into website traffic while prioritizing data privacy and GDPR compliance. It’s a great alternative to Google Analytics for users who want full control over their data without relying on third-party services. This guide will walk you through installing Matomo on a Linux VPS.


Prerequisites

To set up Matomo on your Linux VPS, you’ll need:

  1. A Linux VPS (Ubuntu 20.04 or newer is recommended)
  2. Root access or an account with sudo privileges
  3. LAMP stack (Linux, Apache, MySQL, PHP)
  4. A registered domain name (optional but recommended)

Step 1: Update Your Server

Start by ensuring your server is up-to-date with the latest packages.

				
					sudo apt update && sudo apt upgrade -y
				
			

Step 2: Install Apache Web Server

Matomo requires a web server to function. We’ll use Apache here, but you can also use Nginx if preferred.

				
					sudo apt install apache2 -y
				
			

Enable Apache to start on boot:

				
					sudo systemctl enable apache2
				
			

Step 3: Install PHP and Required Extensions

Matomo needs PHP (version 7.4 or higher) along with several extensions. Install PHP and the necessary extensions with the following command:

				
					sudo apt install php php-cli php-fpm php-mysql php-xml php-mbstring php-curl php-zip -y
				
			

To verify the PHP version:

				
					php -v
				
			

Step 4: Install and Configure MySQL Database

Matomo uses MySQL or MariaDB as its database. Let’s install MySQL and create a database specifically for Matomo.

Install MySQL:

				
					sudo apt install mysql-server -y
				
			

Secure MySQL Installation:.

				
					sudo mysql_secure_installation
				
			

Create a Database for Matomo:

				
					sudo mysql -u root -p
				
			

Inside the MySQL shell, run the following commands:

				
					CREATE DATABASE matomo;
CREATE USER 'matomo_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON matomo.* TO 'matomo_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
				
			

Replace your_secure_password with a strong password. This creates a dedicated Matomo database and user with all necessary permissions.


Step 5: Download and Configure Matomo

Download the Latest Version of Matomo

				
					cd /var/www/html
sudo wget https://builds.matomo.org/matomo.zip
				
			

Extract the Matomo Files:

				
					sudo unzip matomo.zip
sudo rm matomo.zip
				
			

Set the Correct Permissions:

				
					sudo chown -R www-data:www-data /var/www/html/matomo
sudo chmod -R 755 /var/www/html/matomo
				
			

Configure Apache for Matomo:

Create a new configuration file for Matomo.

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

Add the following configuration:

				
					<VirtualHost *:80>
    ServerAdmin admin@yourdomain.com
    DocumentRoot /var/www/html/matomo
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com

    <Directory /var/www/html/matomo/>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
				
			

Replace yourdomain.com with your actual domain. Save and close the file (press CTRL+X, Y, then ENTER).

  1. Enable the New Site and Rewrite Module:

				
					sudo a2ensite matomo.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
				
			

Step 6: Complete Matomo Web Installation

Now that Matomo is configured on the server, complete the installation through the web interface.

  1. Open a browser and go to http://yourdomain.com (replace yourdomain.com with your actual domain or server IP).
  2. Follow the setup wizard:
    • System Check: Matomo will check if your server meets the requirements.
    • Database Setup: Use the database name, username, and password created earlier (matomo, matomo_user, and your_secure_password).
    • Admin Account: Create an admin account for Matomo.
    • Site Setup: Enter details about your website for tracking.
    • Tracking Code: Matomo will provide a tracking code that you can add to the website pages you want to monitor.

Step 7: Enable SSL (Optional but Recommended)

To secure data between your server and users, enable SSL encryption.

Install Certbot:

				
					sudo apt install certbot python3-certbot-apache -y
				
			

Generate an SSL Certificate:

				
					sudo certbot --apache -d yourdomain.com -d www.yourdomain.com
				
			

Follow the prompts to configure the SSL certificate.


Step 8: Access Matomo Dashboard

Once installation is complete, log into your Matomo dashboard at http://yourdomain.com/matomo. Here, you can view insights on site traffic, user behavior, and other analytics.

To start tracking, add the provided tracking code to the <head> section of each page you want to monitor.


With Matomo installed, you now have a private, open-source analytics platform that respects user privacy and meets GDPR requirements. You can now track website traffic, user engagement, and more without relying on third-party analytics platforms like Google Analytics.

Matomo gives you full control over your data and powerful analytics tools tailored to your needs—all hosted securely on your Linux VPS.

Share this Post
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x