Skip to content

How to Install Matomo Web Analytics on Debian 13

Updated 4 min read

Updated: 29 September 2026 · Applies to: Matomo 5.14 on Debian 13 (Apache 2.4, PHP 8.4, MariaDB 11.8)

This guide installs Matomo on Debian 13 with Apache, PHP and MariaDB from Debian's own repositories. Debian 9, which an older version of this article covered, is long out of support. We tested the steps on Debian 13 on 29 September 2026: Matomo 5.14.0 passed all required checks of its installer with PHP 8.4 and MariaDB 11.8.

Matomo (formerly Piwik) is free, open-source web analytics that you host yourself: visitor data stays on your own server instead of going to a third party, which helps with privacy rules such as the GDPR. The current release is Matomo 5.14. Matomo 6, in beta at the time of writing, will need PHP 8.1 or newer and MariaDB 10.6 or newer (or MySQL 8.0); the steps below already meet that.

Before you start

  • A VPS or server with Debian 13 and root access; 2 GB of RAM is enough for small and medium sites.
  • A subdomain such as analytics.example.com with a DNS A record pointing to the server.

Install Apache, PHP and MariaDB

apt update && apt upgrade
apt install apache2 mariadb-server php libapache2-mod-php php-mysql php-xml php-mbstring php-curl php-zip php-gd php-intl unzip curl
systemctl enable --now apache2 mariadb

Create the database

Run mariadb-secure-installation once to remove test data, then create a database and user for Matomo:

mariadb
CREATE DATABASE matomo CHARACTER SET utf8mb4;
CREATE USER 'matomo'@'localhost' IDENTIFIED BY 'a-long-random-password';
GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Download Matomo

cd /var/www
curl -LO https://builds.matomo.org/matomo.zip
unzip -q matomo.zip && rm matomo.zip
chown -R www-data:www-data /var/www/matomo

This always fetches the latest stable release into /var/www/matomo.

Create the Apache site

Create /etc/apache2/sites-available/matomo.conf:

<VirtualHost *:80>
    ServerName analytics.example.com
    DocumentRoot /var/www/matomo
    <Directory /var/www/matomo>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
a2ensite matomo
a2dissite 000-default
a2enmod rewrite
apache2ctl configtest && systemctl reload apache2

Debian does not enable a firewall by default. If you use UFW, allow the web ports with ufw allow 'Apache Full'.

Add a free SSL certificate

apt install certbot python3-certbot-apache
certbot --apache -d analytics.example.com

Certbot renews the certificate automatically; test with certbot renew --dry-run.

Run the web installer

Open https://analytics.example.com and follow the steps:

  1. System check: all required items should be green. (Before HTTPS is set up, Matomo shows a warning that it recommends SSL.)
  2. Database setup: server localhost, the user matomo with its password, and the database matomo.
  3. Super user: your administrator login.
  4. Website: the name and address of the first site to track.
  5. Tracking code: copy the JavaScript snippet into every page of your site, before the closing </head> tag. For WordPress, a Matomo plugin can add it for you.

Archive reports with cron

On busy sites, let a cron job prepare the reports instead of the browser. In Matomo, go to Administration > System > General settings and turn off Archive reports when viewed from the browser. Then create /etc/cron.d/matomo-archive:

5 * * * * www-data /usr/bin/php /var/www/matomo/console core:archive --url=https://analytics.example.com/ > /dev/null

This prepares the reports every hour as the web server user.

Updates

Matomo announces new versions in its interface. Take a database backup (mariadb-dump matomo > matomo.sql), then update from Administration > System > Updates, or on the command line with sudo -u www-data /usr/bin/php /var/www/matomo/console core:update.

Rather not run it yourself? Our Matomo VPS plans include a free Matomo installation with HTTPS and report archiving.

Official documentation: Matomo requirements, installing Matomo and setting up auto-archiving.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket