Matomo (formerly known as Piwik) is a powerful, open-source web analytics platform that allows you to track and analyze your website's traffic. Installing Matomo on Debian 12 is straightforward and provides you with full control over your data. This guide will walk you through the installation process on your VPS server. For reliable hosting solutions, consider using windowsvps for your next VPS server deployment.
Prerequisites
Before you begin, ensure that you have the following:
- A VPS server running Debian 12.
- Root or sudo access to the server.
- A registered domain name pointing to your server's IP address (optional, but recommended).
- Apache, MySQL, and PHP installed on your server.
Step 1: Update Your System
Start by updating your package list and installed packages:
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Packages
Install the necessary packages for Matomo:
sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring php-curl php-zip php-gd php-json unzip -y
Step 3: Configure MySQL Database for Matomo
Log in to the MySQL shell:
sudo mysql -u root -p
Create a database and user for Matomo:
CREATE DATABASE matomo;
CREATE USER 'matomouser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON matomo.* TO 'matomouser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4: Download Matomo
Navigate to the web directory and download the latest version of Matomo:
cd /var/www/html
wget https://builds.matomo.org/matomo-latest.zip
Unzip the downloaded file:
unzip matomo-latest.zip
rm matomo-latest.zip
Step 5: Set Up Directory Permissions
Set the ownership of the Matomo directory to the Apache user:
sudo chown -R www-data:www-data /var/www/html/matomo
Set the correct permissions:
sudo chmod -R 755 /var/www/html/matomo
Step 6: Configure Apache for Matomo
Create a new Apache configuration file for Matomo:
sudo nano /etc/apache2/sites-available/matomo.conf
Add the following configuration:
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/html/matomo
<Directory /var/www/html/matomo>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/matomo-error.log
CustomLog ${APACHE_LOG_DIR}/matomo-access.log combined
</VirtualHost>
Replace yourdomain.com
with your actual domain name.
Step 7: Enable the Matomo Site
Enable the new site and rewrite module:
sudo a2ensite matomo.conf
sudo a2enmod rewrite
Then restart Apache:
sudo systemctl restart apache2
Step 8: Complete the Installation via Web Interface
Open your web browser and navigate to http://yourdomain.com
. You should see the Matomo setup page. Follow the prompts to complete the installation, providing the database details created earlier.
Conclusion
By following these steps, you have successfully installed Matomo Web Analytics on your Debian 12 VPS server. This powerful analytics tool allows you to track and analyze your website's performance effectively. For optimal performance and reliable hosting, consider utilizing windowsvps for your next VPS server hosting solution.