Install dependencies
apt install apache2 mariadb-server php8.2-{curl,gd,cli,mysql,xml,mbstring}
Create a new site config file
vim /etc/apache2/sites-available/matomo.conf
Use the following config (modify as needed)
<VirtualHost *:80>
ServerName analytics.example.com
DocumentRoot /var/www/matomo
DirectoryIndex index.php
</VirtualHost>
Disable the default site and enable the Matomo site
a2dissite 000-default.conf
a2ensite matomo.conf
systemctl reload apache2.service
Run the installer
mysql_secure_installation
Login to MariaDB
mysql -u root
Create a new database
CREATE DATABASE matomo;
Create a new user for Matomo to use
CREATE USER 'matomo'@'localhost' IDENTIFIED BY '********************';
Grant permission to the matomo
user to the matomo
database
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, DROP, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON matomo.* TO 'matomo'@'localhost';
Download Matomo and extract it into /var/www/
wget https://builds.matomo.org/matomo.zip && unzip matomo.zip -d /var/www/
Change ownership of all directories/files
chown www-data:www-data /var/www/matomo/* -R
Browse to the server IP and run through the installation.