How To Install Matomo on Fedora 41
In the realm of web analytics, understanding user behavior is paramount. Matomo emerges as a powerful, open-source alternative to Google Analytics, offering enhanced privacy and complete data ownership. This guide provides a detailed walkthrough on how to install Matomo on Fedora 41, ensuring you can harness its capabilities for your website. We will explore everything from system requirements to security configurations. The key is to provide helpful, step-by-step instructions.
Why Choose Matomo?
Matomo distinguishes itself with several key advantages. Unlike Google Analytics, Matomo allows you to retain complete control over your data. This is especially vital for organizations prioritizing user privacy and compliance with regulations like GDPR. Additionally, Matomo offers extensive customization options and a wide array of plugins to tailor the analytics platform to your specific needs.
Key Features and Benefits
- Data Ownership: Complete control over your analytics data.
- Enhanced Privacy: Respect user privacy with features like anonymization and consent management.
- Customization: Tailor the platform with numerous plugins and integrations.
- Open Source: Benefit from a transparent and community-driven platform.
- Real-Time Analytics: Monitor website activity as it happens.
This tutorial aims to equip you with the knowledge and steps necessary to install and configure Matomo on Fedora 41. Let’s delve into the process.
System Requirements
Before proceeding with the installation, it’s crucial to ensure that your system meets the necessary requirements. These include both hardware and software specifications. Let’s examine what you need.
Hardware Requirements
The performance of Matomo heavily depends on the hardware resources allocated to it. Meeting the minimum requirements is vital for optimal performance. If you anticipate high traffic, consider the recommended specifications.
Minimum Server Specifications
- RAM: 512 MB
- CPU: 1 GHz
- Storage: 10 GB
These specifications are suitable for small websites with limited traffic. For larger sites, consider more robust hardware.
Recommended Server Specifications
- RAM: 2 GB or more
- CPU: 2 GHz or more
- Storage: 40 GB or more
These specifications ensure smooth operation and the capacity to handle increased data processing demands. Ensure that you have the resources you need.
Software Prerequisites
In addition to hardware, specific software components must be installed and configured correctly. These include a web server, a database, and PHP. Let’s explore these requirements in detail.
Required Packages
Fedora 41 requires a few essential packages to be installed for Matomo to function correctly. These include:
- Apache or Nginx: Web server to serve Matomo files.
- MariaDB or MySQL: Database to store analytics data.
- PHP: Programming language to run Matomo.
These components form the foundation of the Matomo installation. We will guide you through installing and configuring each.
PHP Version Requirements
Matomo requires a specific version of PHP to operate correctly. Ensure that your system meets these requirements to prevent compatibility issues.
- PHP Version: 7.2 or higher (ideally PHP 7.4 or 8.0 for better performance)
- PHP Extensions:
PDO
pdo_mysql
orpdo_pgsql
mysqli
curl
gd
mbstring
xml
zlib
json
session
These extensions are vital for Matomo to process data and interact with the database. Make sure they are enabled in your PHP configuration.
Database Requirements
Matomo supports both MySQL and MariaDB. Choose one based on your preference and system configuration.
- MySQL: Version 5.5 or higher
- MariaDB: Version 10.1 or higher
Ensure that your chosen database server is running and accessible. You’ll need credentials to create a database and user for Matomo.
Web Server Compatibility
Matomo is compatible with both Apache and Nginx web servers. This guide focuses on Apache, but the general principles apply to Nginx as well.
- Apache: Version 2.4 or higher
- Nginx: Version 1.10 or higher
Choose the web server that best fits your infrastructure and expertise. The configuration steps will vary slightly depending on your choice.
Preparing the Environment
Preparing the environment involves updating the system, installing necessary utilities, and setting up the LAMP stack (Linux, Apache, MySQL, PHP). This ensures a smooth installation process. Let’s start with system updates.
System Updates
Keeping your system up-to-date is crucial for security and stability. Start by updating the package repositories and installing essential utilities.
Updating Package Repositories
Open a terminal and run the following commands to update the package repositories:
sudo dnf update
sudo dnf upgrade
This ensures that you have the latest package information and security patches. Regular updates are essential for maintaining a secure system.
Installing Essential Utilities
Install essential utilities that will aid in the installation and configuration process:
sudo dnf install nano wget unzip
nano
is a text editor, wget
is used for downloading files, and unzip
is used for extracting compressed files. These tools will be used throughout the tutorial.
LAMP Stack Installation
The LAMP stack is a bundle of software that allows you to host dynamic websites and applications. It includes Apache, MariaDB, and PHP. Let’s install and configure each component.
Apache Web Server Setup
Install the Apache web server using the following command:
sudo dnf install httpd
After installation, start and enable the Apache service:
sudo systemctl start httpd
sudo systemctl enable httpd
Verify that Apache is running by accessing your server’s IP address in a web browser. You should see the Apache test page.
MariaDB Installation
Install the MariaDB server using the following command:
sudo dnf install mariadb-server mariadb
Start and enable the MariaDB service:
sudo systemctl start mariadb
sudo systemctl enable mariadb
Secure the MariaDB installation by running the mysql_secure_installation
script:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disallow remote root login, and remove the test database.
PHP and Required Extensions
Install PHP and the necessary extensions using the following command:
sudo dnf install php php-pdo php-mysqlnd php-curl php-gd php-mbstring php-xml php-zip php-json php-session
Verify the installed PHP version:
php -v
Ensure that the version meets Matomo’s requirements. Also, verify that all the required extensions are enabled in the PHP configuration file (php.ini
).
Database Configuration
Configuring the database involves securing the MariaDB installation, creating a database for Matomo, setting up a database user, and configuring permissions. This ensures that Matomo can store and retrieve data correctly. The database needs to be properly configured for everything to work right.
MariaDB Setup
Properly setting up MariaDB is crucial for the security and functionality of Matomo. Follow these steps to ensure a secure and efficient database configuration.
Securing MariaDB Installation
As mentioned earlier, the mysql_secure_installation
script helps secure the MariaDB installation. Run the script and follow the prompts:
sudo mysql_secure_installation
This script sets a root password, removes anonymous users, disallows remote root login, and removes the test database. It’s a vital step in securing your database server.
Creating Matomo Database
Log in to the MariaDB server as the root user:
sudo mysql -u root -p
Enter the root password when prompted. Create a new database for Matomo:
CREATE DATABASE matomo;
Setting Up Database User
Create a new user for Matomo with a strong password:
CREATE USER 'matomo'@'localhost' IDENTIFIED BY 'your_strong_password';
Replace your_strong_password
with a secure password.
Configuring Permissions
Grant the necessary permissions to the Matomo user on the Matomo database:
GRANT ALL PRIVILEGES ON matomo.* TO 'matomo'@'localhost';
FLUSH PRIVILEGES;
EXIT;
This ensures that the Matomo user has full access to the Matomo database. Remember to flush the privileges to apply the changes.
Web Server Configuration
Configuring the web server involves creating a virtual host, setting up SSL/TLS, configuring necessary modules, and setting proper permissions. This allows Matomo to be accessed securely over the internet. Make sure your configuration is correct.
Apache Configuration
Configuring Apache involves creating a virtual host for Matomo and enabling necessary modules. Follow these steps to ensure a proper setup.
Creating Virtual Host
Create a new virtual host configuration file for Matomo:
sudo nano /etc/httpd/conf.d/matomo.conf
Add the following configuration:
<VirtualHost *:80>
ServerName matomo.example.com
DocumentRoot /var/www/matomo
<Directory /var/www/matomo>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/matomo_error.log
CustomLog /var/log/httpd/matomo_access.log combined
</VirtualHost>
Replace matomo.example.com
with your domain name and /var/www/matomo
with the directory where you will install Matomo. Make sure that you adapt this information.
Setting Up SSL/TLS
To secure your Matomo installation with SSL/TLS, you can use Let’s Encrypt. Install the Certbot client:
sudo dnf install certbot python3-certbot-apache
Obtain an SSL certificate:
sudo certbot --apache -d matomo.example.com
Follow the prompts to complete the SSL setup. Certbot will automatically configure Apache to use the SSL certificate.
Configuring Necessary Modules
Ensure that the necessary Apache modules are enabled:
sudo a2enmod rewrite
sudo a2enmod headers
Restart Apache to apply the changes:
sudo systemctl restart httpd
Permission Settings
Set proper permissions for the Matomo directory:
sudo chown -R apache:apache /var/www/matomo
sudo chmod -R 755 /var/www/matomo
This ensures that Apache can read and write files in the Matomo directory.
Installing Matomo
Installing Matomo involves downloading the latest release, verifying the package integrity, extracting the files, and setting proper permissions. Then, you’ll use the web-based setup wizard to complete the installation. Let’s go through each step.
Download and Extraction
Downloading and extracting the Matomo package is the first step in the installation process. Ensure that you download the latest version from the official website.
Obtaining Latest Matomo Release
Download the latest Matomo release from the official website using wget
:
sudo wget https://builds.matomo.org/latest.zip -O matomo.zip
This command downloads the latest version of Matomo as a ZIP file.
Verifying Package Integrity
Verify the integrity of the downloaded package by checking its SHA256 checksum. You can find the checksum on the Matomo website.
sha256sum matomo.zip
Compare the output with the checksum on the website to ensure that the package is not corrupted.
Extracting Files
Extract the files to the web server’s document root:
sudo unzip matomo.zip -d /var/www
Rename the extracted directory to matomo
:
sudo mv /var/www/matomo /var/www/html/matomo
Setting Proper Permissions
Set proper permissions for the Matomo directory:
sudo chown -R apache:apache /var/www/html/matomo
sudo chmod -R 755 /var/www/html/matomo
This ensures that Apache can read and write files in the Matomo directory.
Web-based Setup
The web-based setup wizard guides you through the final steps of the installation process. Access the wizard through your web browser.
Accessing Installation Wizard
Open your web browser and navigate to http://matomo.example.com
. You should see the Matomo installation wizard.
System Check Process
The wizard will perform a system check to ensure that all requirements are met. If any issues are found, resolve them before proceeding.
Database Connection Setup
Enter the database connection details:
- Database Server: localhost
- Database Name: matomo
- Database User: matomo
- Database Password: your_strong_password
- Table Prefix: matomo_
Click “Next” to test the connection.
Administrator Account Creation
Create an administrator account for Matomo:
- Username: admin
- Password: your_admin_password
- Email: your_email@example.com
Click “Next” to create the account. Follow the remaining prompts to complete the installation. The installation is simple.
Security Configurations
Securing your Matomo installation is crucial to protect your data and prevent unauthorized access. Implement the following hardening measures to enhance security. Keep your site safe and secure.
Hardening Measures
Implementing these hardening measures will significantly enhance the security of your Matomo installation.
File Permissions
Ensure that file permissions are set correctly to prevent unauthorized access:
sudo chmod -R 755 /var/www/html/matomo
sudo chmod 644 /var/www/html/matomo/config/config.ini.php
This ensures that only the Apache user can modify the configuration file.
SELinux Configuration
Configure SELinux to further restrict access to Matomo files. Create a custom SELinux policy:
sudo nano matomo.te
Add the following policy:
module matomo 1.0;
require {
type httpd_t;
type var_log_t;
type mysqld_db_t;
class file { read write execute getattr };
class dir { search read write getattr add_name };
class tcp_socket name_connect;
}
# Allow Apache to read and write Matomo files
allow httpd_t mysqld_db_t:file { read write execute getattr };
allow httpd_t var_log_t:file { write create append getattr };
allow httpd_t self:tcp_socket name_connect;
# Allow Apache to search, read, write, and getattr Matomo directories
allow httpd_t default_t:dir { search read write getattr add_name };
Compile and install the policy:
checkmodule -M -m -o matomo.mod matomo.te
semodule_package -m matomo.mod -o matomo.pp
sudo semodule -i matomo.pp
Firewall Settings
Configure the firewall to allow access to Matomo:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
This allows HTTP and HTTPS traffic to reach your Matomo installation.
SSL Implementation
Ensure that SSL/TLS is properly implemented to encrypt traffic between the client and server. This protects sensitive data from eavesdropping.
Post-Installation Steps
After installation, it’s essential to verify the installation, test the tracking code, and verify data collection. This ensures that Matomo is functioning correctly. Verify the tracking process.
Verification and Testing
These steps will help you ensure that Matomo is installed correctly and collecting data as expected.
Checking Installation
Verify that Matomo is installed correctly by accessing the Matomo dashboard in your web browser. Log in with the administrator account you created during the installation process.
Testing Tracking Code
Add the Matomo tracking code to your website. You can find the tracking code in the Matomo dashboard under “Websites” -> “Manage”. Copy the code and paste it into your website’s HTML.
Verifying Data Collection
Visit your website and check the Matomo dashboard to see if data is being collected. You should see real-time data appearing in the dashboard. This confirms that the tracking code is working correctly.
Maintenance and Updates
Regular maintenance and updates are crucial for keeping your Matomo installation secure and performing optimally. Implement the following procedures to ensure a healthy Matomo environment. This includes regular backups.
Backup Procedures
Regularly back up your Matomo database and files to prevent data loss. You can use mysqldump
to back up the database:
sudo mysqldump -u root -p matomo > matomo_backup.sql
Back up the Matomo files:
sudo tar -czvf matomo_backup.tar.gz /var/www/html/matomo
Update Process
Keep Matomo up-to-date to benefit from the latest features and security patches. You can update Matomo through the web-based interface or by downloading the latest version and replacing the existing files.
Regular Maintenance Tasks
Perform regular maintenance tasks such as:
- Checking server logs for errors
- Optimizing the database
- Reviewing user permissions
- Updating plugins and themes
Troubleshooting Common Issues
Even with careful planning and execution, you may encounter issues during the installation or configuration process. Here are some common problems and their solutions.
Permission Problems
If you encounter permission problems, ensure that the Apache user has the necessary permissions to read and write files in the Matomo directory. Use the chown
and chmod
commands to set proper permissions.
Database Connection Issues
If you encounter database connection issues, verify that the database server is running and accessible. Check the database credentials in the Matomo configuration file (config.ini.php
) to ensure that they are correct.
PHP Configuration Errors
If you encounter PHP configuration errors, check the PHP error logs for details. Ensure that all required PHP extensions are enabled in the PHP configuration file (php.ini
). Restart the Apache service after making changes to the PHP configuration.
Web Server Conflicts
If you encounter web server conflicts, ensure that there are no conflicting virtual host configurations. Check the Apache configuration files for errors. Restart the Apache service after making changes.
Congratulations! You have successfully installed Matomo. Thanks for using this tutorial for installing Matomo web analytics on your Fedora 41 system. For additional help or useful information, we recommend you check the official Matomo website.