This guide installs Matomo on a traditional LAMP/LEMP stack. For a Docker-based install, see Matomo on Docker Compose.
Refer to the official Matomo requirements page for the exact supported versions and extensions.
sudo apt update
sudo apt install -y apache2 mariadb-server php php-cli php-mysql php-gd php-xml php-curl php-mbstring unzip
sudo mysql -u root -p
CREATE DATABASE matomo_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'matomo_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON matomo_db.* TO 'matomo_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
cd /var/www/html
wget https://builds.matomo.org/matomo-latest.zip
unzip matomo-latest.zip
rm matomo-latest.zip
sudo chown -R www-data:www-data /var/www/html/matomo
<VirtualHost *:80>
ServerName analytics.example.com
DocumentRoot /var/www/html/matomo
<Directory /var/www/html/matomo>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Enable the site and reload Apache:
sudo a2ensite matomo.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
server {
listen 80;
server_name analytics.example.com;
root /var/www/html/matomo;
index index.php;
location / {
try_files $uri /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Reload Nginx:
sudo systemctl reload nginx
Open http://analytics.example.com and follow the Matomo installer:
Use Certbot (or your preferred method) to enable TLS. For example:
sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache
Check the Matomo installation documentation or reach out via our contact page.