How to Install Matomo with LAMP Stack on Debian 13

Matomo, formerly Piwik, is a free and open-source web analytics application developed by a team of international developers, that runs on a PHP/MySQL webserver. It tracks online visits to one or more websites and displays reports on these visits for analysis. In this article, we are going to learn how to install Matomo on Debian 13. So, let’s get started.

Checkout the Matomo Project Here.

Try this wiki on our VPS. Starting at just $5/month with 24x7 In-house customer support.

Pre-requisites

  • A system with Debian 13 installed and running.

  • root access to the system.

  • LAMP Stack installed and running, for this, you can refer to one of our guides on installing the LAMP Stack (Apache, MariaDB, and PHP).

Once you're all set, we'll proceed with Matomo installation and configuration.

Create Database

Let us begin with creating a Database and a user. We will then grant the required privileges to the user so it can interact with the Database.

mysql -u root -p

CREATE DATABASE matomo_db;

CREATE USER 'matomo_user'@'localhost' IDENTIFIED BY 'YOUR-PASSWORD-HERE';

GRANT ALL PRIVILEGES ON matomo_db.* TO 'matomo_user'@'localhost';

FLUSH PRIVILEGES;

EXIT;

The above commands will give complete access to the user matomo_user. Replace YOUR-PASSWORD-HERE with a safe and secure password.

Install Let’s Encrypt SSL Certificate

Let's issue an SSL certificate for the domain. For this, we will install the snap package manager on Debian.

First, update and install snapd:

apt update

apt install -y snapd

snap install core && sudo snap refresh core

Next, install Certbot using snap:

snap install --classic certbot

ln -s /snap/bin/certbot /usr/bin/certbot

Now use Certbot to automatically issue and install SSL for Apache:

certbot --apache

Download Matomo

Download Matomo from the official website: Click here.

Install the unzip package:

apt install unzip

cd /var/www/

wget https://builds.matomo.org/matomo.zip && unzip matomo.zip

rm matomo.zip

cd matomo

mkdir tmp

Setting up File Permissions

Let's make the folders readable:

chown -R www-data:www-data /var/www/matomo

chmod -R 755 /var/www/matomo

Configuring Apache vHost

Create a new apache configuration file dev.domainhere.info.conf for the domain with the following command:

vi /etc/apache2/sites-available/dev.domainhere.info.conf

Add the following configuration:

<VirtualHost *:80>

ServerName dev.domainhere.info ServerAlias dev.domainhere.info ServerAdmin admin@dev.domainhere.info DocumentRoot /var/www/matomo

ErrorLog ${APACHE_LOG_DIR}/dev.domainhere.info_error.log CustomLog ${APACHE_LOG_DIR}/dev.domainhere.info_access.log combined

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

Change dev.domainhere.info with your actual Domain Name.

Press Esc, type :wq! and hit Enter to save and exit.

Edit the PHP config file php.ini using nano or vi:

nano /etc/php/8.2/apache2/php.ini

Add the following lines at the end:

extension=mysqli.so extension=pdo.so extension=pdo_mysql.so

Save and exit the file.

Disable the default config and enable your new site config:

a2dissite 000-default.conf

a2ensite dev.domainhere.info.conf

Now restart Apache:

systemctl restart apache2

systemctl status apache2

Enable Firewall:

ufw allow 80/tcp

ufw allow 443/tcp

Configuring Matomo

Now open the URL from your browser. This will redirect you to the Matomo web installer:

https://dev.domainhere.info

Replace the dev.domainhere.info with the actual IP or domain configured on the server.

Input the database details configured earlier. Follow the on-screen steps:

images

images

images

images

images

images

images

images

images

images

images

Now you have successfully installed Matomo with LAMP Stack on Debian 13.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS