Skip to content

How to Install Matomo Web Analytics on AlmaLinux and Rocky Linux 9 and 10

Updated 4 min read

Updated: 29 September 2026 · Applies to: Matomo 5.14 on AlmaLinux and Rocky Linux 9 and 10 (Apache 2.4, PHP 8.3, MariaDB 10.11)

This guide installs Matomo on AlmaLinux or Rocky Linux 9 or 10 with Apache, PHP-FPM and MariaDB. CentOS 7, which an older version of this article covered, reached end of life in June 2024. We tested the steps on 29 September 2026: Matomo 5.14.0 passed all required checks of its installer on AlmaLinux 10 (PHP 8.3, MariaDB 10.11) and on AlmaLinux 9 with PHP 8.3.

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 AlmaLinux or Rocky Linux 9 or 10 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

On version 9 only, first switch to newer PHP and MariaDB versions. The defaults, PHP 8.0 and MariaDB 10.5, work with Matomo 5 but are older than Matomo 6 will require:

dnf module reset php mariadb
dnf module enable php:8.3 mariadb:10.11

Then, on version 9 and 10:

dnf upgrade
dnf install httpd mariadb-server php php-fpm php-mysqlnd php-xml php-mbstring php-gd php-intl php-pecl-zip unzip
systemctl enable --now httpd mariadb php-fpm
firewall-cmd --permanent --add-service=http --add-service=https && firewall-cmd --reload

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 apache:apache /var/www/matomo

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

Create the Apache site

Create /etc/httpd/conf.d/matomo.conf:

<VirtualHost *:80>
    ServerName analytics.example.com
    DocumentRoot /var/www/matomo
    <Directory /var/www/matomo>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
apachectl configtest && systemctl reload httpd

SELinux

SELinux is enforcing by default. Let Apache write to Matomo's configuration and temporary folders, and allow the outgoing connections Matomo uses for update checks:

semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/matomo/(config|tmp)(/.*)?"
restorecon -R /var/www/matomo
setsebool -P httpd_can_network_connect 1

semanage is in the policycoreutils-python-utils package. Using localhost as the database server lets PHP connect through MariaDB's socket, which SELinux allows without further changes.

Add a free SSL certificate

dnf install epel-release
dnf install certbot python3-certbot-apache mod_ssl
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 * * * * apache /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 apache /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