Setting up Matomo involves installing it directly on a server using traditional methods.
Here’s a step-by-step guide for setting up Matomo. If you want to run Matomo on Docker with docker-compose, check this guide.
Before installing Matomo, ensure the following are available on your server:
Install these PHP extensions:
mysqlipdo_mysqlgdzlibcurlmbstringxmljsonsessionopensslsudo apt update && sudo apt upgrade -y
sudo apt install apache2 mysql-server php libapache2-mod-php php-cli php-mysql php-gd php-xml php-curl php-mbstring unzip -y
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
sudo chmod -R 755 /var/www/html/matomo
sudo nano /etc/apache2/sites-available/matomo.conf
<VirtualHost *:80>
ServerName your-domain.com
DocumentRoot /var/www/html/matomo
<Directory /var/www/html/matomo>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/matomo_error.log
CustomLog ${APACHE_LOG_DIR}/matomo_access.log combined
</VirtualHost>
sudo a2ensite matomo.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo nano /etc/nginx/sites-available/matomo
server {
listen 80;
server_name your-domain.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/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
sudo ln -s /etc/nginx/sites-available/matomo /etc/nginx/sites-enabled/
sudo systemctl restart nginx
http://your-domain.com.For real world use you need to enable SSL for your Matomo Instance. Without https, no browser will accept it.
If you want to use a self-generated Cert or if you want to buy a cert, you will need additional steps.
Mostly we use Certbot and Letsencrypt. Certbot will change the configuration of your webserver on its own.
Use Certbot to enable HTTPS:
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache
Or for Nginx:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx
If you encounter issues, check the following:
Feel free to contact us. Find all contact information on our contact page.