How to Install Matomo (Piwik) on RHEL 8 Linux

This article covers an installation of Matomo (Piwik), an all-in-one premium web analytics platform, on RHEL 8 Linux Server. In this instance the installation is based on the well-know LAMP stack comprising the RHEL 8, MariaDB, PHP and Apache webserver.

In this tutorial you will learn:

  • How to Install LAMP Stack on RHEL 8.
  • How to configure MariaDB database.
  • How to install Matomo (Piwik) on RHEL 8.
  • How to open HTTP and HTTPS firewall ports.

Installed Matomo (Piwik) on Red Hat Enterprise Linux 8 Server/Workstation.

Installed Matomo (Piwik) on Red Hat Enterprise Linux 8 Server/Workstation.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Red Hat Enterprise Linux 8
Software MariaDB Server 10.3.10, PHP 7.2.11-1, Apache/2.4.35 (Red Hat Enterprise Linux)
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to install Matomo (Piwik) on RHEL 8 Linux step by step instructions



  1. Install all prerequisites.

    The following command will install all prerequisites and tools required to perform the Matomo (Piwik) installation:

    # dnf install php-mysqlnd php-fpm mariadb-server httpd unzip wget php-json php-dom php-gd php-mbstring
    
  2. Open HTTP and optionally HTTPS port 80 on your firewall:
    # firewall-cmd --permanent --zone=public --add-service=http 
    # firewall-cmd --reload
    
  3. Start both the Apache webserver and the MariaDB services:
    # systemctl start mariadb
    # systemctl start httpd
    

    Enable MariaDB and httpd to start after system reboot:

    # systemctl enable mariadb
    # systemctl enable httpd
    
  4. (Optional) Secure your MariaDB installation and set root password:
    # mysql_secure_installation
    


  5. Create a new database matomo and give the new user admin access to the matomo database with the password pass:
    # mysql -u root -p
    mysql> CREATE DATABASE matomo;
    mysql> CREATE USER `admin`@`localhost` IDENTIFIED BY 'pass';
    mysql> GRANT ALL ON matomo.* TO `admin`@`localhost`;
    mysql> FLUSH PRIVILEGES;
    mysql> exit
    
  6. Download and extract Matomo (Piwik). Start by downloading the Matomo (Piwik) installation package and extracting its content:
    $  wget https://builds.matomo.org/matomo-latest.zip
    $ unzip matomo-latest.zip 
    

    Copy the extracted matomo directory into the /var/www/html directory:

    # cp -r matomo /var/www/html/
    

    Lastly in this step, change permissions and change file SELinux security context:

    # chown -R apache:apache /var/www/html/
    # chcon -R -t httpd_sys_rw_content_t /var/www/html/matomo/
    
  7. Access Matomo (Piwik) installation wizard and perform the actual Matomo (Piwik) installation. Navigate your browser to http://localhost/matomo or http://SERVER-HOST-NAME/matomo and follow the instructions.


    Matomo installation wizard welcome page.

    Matomo installation wizard welcome page. Press NEXT to begin the installation.

    All Matomo (Piwik) installation pre-requisites satisfied.

    All Matomo (Piwik) installation pre-requisites satisfied.

    Configure matomo database

    Change Database Server to localhost to avoid permission denied error message. Fill in all database configurations as per Step 5.



    Create matomo tables.

    Press NEXT to create all tables.

    Setup super user Matomo user account.

    Setup super user Matomo user account.

    Fill in your website details.

    Fill in your website details.



    Copy and paste the resulting tracking code into the HEAD section of your website.<

    Copy and paste the resulting tracking code into the HEAD section of your website.

    Matomo (Piwik) installation on Red Hat Enterprise Linux 8 Completed.

    Matomo (Piwik) installation on Red Hat Enterprise Linux 8 Completed.