In this article, we will have explained the necessary steps to install Matomo Web Analytics on Debian 11. Before continuing with this tutorial, make sure you are logged in as a user with sudo
privileges. All the commands in this tutorial should be run as a non-root user.
Matomo, formerly Piwik, is a free, open-source web analytics software tool. It is used to track your website and give detailed information on your website and its visitors, including the search engines and keywords they used, the language they speak, which pages they like, the files they download and so much more.
Install Matomo Web Analytics on Debian 11
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo apt update sudo apt upgradesudoapt install software-properties-common wget
Step 2. Install LAMP stack.
You’re going to need to set Debian up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up Debian to serve before you continue.
Step 3. Install Matomo on the Debian system.
Installing Matomo on your Debian system is straightforward, All you need to do is open a terminal and run the following command to download the latest release version of Matomo from the Matomo release page:
wget http://builds.matomo.org/matomo-latest.zip
Extract the .zip
file into the webroot directory of your system:
unzip matomo-latest.zip mv matomo /var/www/html/matomo
Then, change ownership of the installation directory:
chown -R www-data:www-data /var/www/html/matomo chmod -R 755 /var/www/html/matomo
Step 4. Creating a Database for Matomo.
Matomo uses the MariaDB database to store all its data. Log in to your MariaDB server with the following command and enter your MariaDB root password:
mysql -u root -p
Once you’re in the MariaDB console, create a new database:
MariaDB [(none)]> CREATE DATABASE matomodb; MariaDB [(none)]> CREATE USER 'matomouser'@'localhost' IDENTIFIED BY 'your-password'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON matomodb.* TO 'matomouser'@'localhost'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> EXIT;
Step 5. Create the Apache Virtual Host for Matomo.
The last part is to create a configuration file or virtual host file for Matomo. So, using your favorite text editor, create the file below:
sudo nano /etc/apache2/sites-available/matomo.conf
Add the following lines in the configuration file using nano editor:
<VirtualHost *:80> ServerAdmin [email protected] ServerName example.com DocumentRoot /var/www/html/matomo/ <Directory /var/www/html/matomo> DirectoryIndex index.php Options FollowSymLinks AllowOverride All Require all granted </Directory> <Files "console"> Options None Require all denied </Files> <Directory /var/www/html/matomo/misc/user> Options None Require all granted </Directory> <Directory /var/www/html/matomo/misc> Options None Require all denied </Directory> <Directory /var/www/html/matomo/vendor> Options None Require all denied </Directory> ErrorLog ${APACHE_LOG_DIR}/matomo_error.log CustomLog ${APACHE_LOG_DIR}/matomo_access.log combined </VirtualHost>
Don’t forget to restart Apache and ensure all the alterations are successfully applied:
sudo a2ensite matomo.conf sudo a2enmod rewrite sudo systemctl restart apache2
Step 6. Accessing Matomo Web UI.
Finally, steps, open your web browser and type the URL http://example.com
. You will be redirected to the Matomo welcome screen:
That’s all you need to do to install Matomo on Debian (Bullseye). I hope you find this quick tip helpful. For further reading Matomo’s web analytics platform on Debian’s system, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.