How to Install Matomo on CentOS 8

Install Matomo CentOS 8

In this article, we will have explained the necessary steps to install and configure Matomo on CentOS 8. 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 is an open-source PHP application that you can run yourself, putting you in control of your analytics platform. Plus, Matomo actually respects your users and doesn’t try to break tracking protection. Matomo/Piwik is an alternative to Google Analytics software that gives you full control of your own website analytics and data without using third-party solutions. It is designed for small and medium-sized businesses that can be used to track Key Performance Indicators such as visits, downloads, goal conversion rates, keywords, and many more.

Install Matomo on CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf install epel-release
sudo dnf update

Step 2. Install LAMP Stack.

Matomo is built with PHP. You can host it like you would any other web app is written in PHP. So, you’re going to need to set CentOS up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up CentOS to serve PHP before you continue.

Step 3. Download and Install Matomo on the CentOS system.

Now download and extract Matomo using the command below:

wget https://builds.matomo.org/matomo-latest.zip
unzip matomo-latest.zip
cp -r matomo /var/www/html/

Change the owner and set the correct permissions for these files, you need to run the following command:

chown -R apache:apache /var/www/html/
chcon -R -t httpd_sys_rw_content_t /var/www/html/matomo/

Step 4. Create a Database for Matomo.

Create a database and user that Matomo will use. Get this accomplished as illustrated below. You are free to name your database and user differently and ensure you use a safe password. 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:

CREATE DATABASE matomo_db;
CREATE USER matomo_user@localhost IDENTIFIED BY 'your-strong-password';
GRANT ALL PRIVILEGES ON matomo_db.* TO matomo_user@localhost;
FLUSH PRIVILEGES;
exit;

Step 5. Configure Firewall.

Modify firewall rules in order to allow port 80 or 443 as you wish:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload

Step 6. Accessing Matomo on CentOS.

Finally, steps, open your web browser and type the URL http://your-domain.com/matomo. You will be redirected to the Matomo welcome screen:

Install Matomo on CentOS 8

That’s all you need to do to install Matomo on CentOS 8. I hope you find this quick tip helpful. For further reading on Matomo Web Analytics, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.