Skip to content

matomo

Installation

 cd /var/www/html/
 wget https://builds.matomo.org/matomo-latest.zip
 unzip matomo-latest.zip -d /var/www/html/
 chown -R www-data:www-data /var/www/html/matomo 

Now Create a Database and User in MariaDB

Log into MariaDB database server with the following command.

mysql

Ceate a database for Matomo

create database matomo;

Create the database user.

SET GLOBAL validate_password.LENGTH = 4;
SET GLOBAL validate_password.policy = 0;
SET GLOBAL validate_password.mixed_case_count = 0;
SET GLOBAL validate_password.number_count = 0;
SET GLOBAL validate_password.special_char_count = 0;
SET GLOBAL validate_password.check_user_name = 0;
create user wuseman@localhost identified by 'ChangeThisPassword';
FLUSH PRIVILEGES;

Grant this user all privileges on the matomo database.

grant all privileges on matomo.* to wuseman@localhost;

Flush privileges and exit.

flush privileges;
exit;

Create Apache Configuration File

cat << "EOF" > /etc/apache2/sites-available/matomo.conf
<VirtualHost *:80>
        ServerAdmin wuseman@nr1.se
        ServerName stats.nr3.se
        DocumentRoot /var/www/matomo
        php_admin_value engine on
        <Directory /var/www/matomo>
           DirectoryIndex index.php
           Options FollowSymLinks
           AllowOverride All
           Require all granted
           php_admin_value engine on
        </Directory>

        <Files "console">
           Options None
           Require all denied
        </Files>

        <Directory /var/www/matomo/misc/user>
           Options None
           Require all granted
        </Directory>

        <Directory /var/www/matomo/misc>
           Options None
           Require all denied
        </Directory>

        <Directory /var/www/matomo/vendor>
           Options None
           Require all denied
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/matomo_error.log
        CustomLog ${APACHE_LOG_DIR}/matomo_access.log combined

</VirtualHost>
EOF

Save and close the file. Then enable this virtual host.

a2ensite matomo.conf

Install required php modules for Matomo

apt install php-imagick php8.1-mysql php8.1-fpm php8.1-common php8.1-gd php8.1-curl  php8.1-zip php8.1-xml php8.1-mbstring php8.1-bz2 php8.1-intl

Reload Apache web server for the change to take effect.

/etc/init.d/apache2 restart

Enable HTTPS

To encrypt the HTTP traffic when you visit the Matomo web interface, we can enable HTTPS by installing a free TLS certificate issued from Let’s Encrypt. Run the following commands to install Let’s Encrypt client (certbot) on Ubuntu 20.04.

=== "Debian"
    ```bash
    apt install certbot python3-certbot-apache
    ```

=== "Gentoo"
    ```bash
    emerge app-crypt/certbot app-crypt/certbot-apache
    ```

Then run the following command to obtain and install TLS certificate.

certbot -d nr0.se -d www.nr0.se --apache

Permissions problem

chown -R apache:apache /var/www/localhost/htdocs/matomo
find /var/www/localhost/htdocs/matomo/tmp -type f -exec chmod 644 {} \;
find /var/www/localhost/htdocs/matomo/tmp -type d -exec chmod 755 {} \;
find /var/www/localhost/htdocs/matomo/tmp/assets/ -type f -exec chmod 644 {} \;
find /var/www/localhost/htdocs/matomo/tmp/assets/ -type d -exec chmod 755 {} \;
find /var/www/localhost/htdocs/matomo/tmp/cache/ -type f -exec chmod 644 {} \;
find /var/www/localhost/htdocs/matomo/tmp/cache/ -type d -exec chmod 755 {} \;
find /var/www/localhost/htdocs/matomo/tmp/logs/ -type f -exec chmod 644 {} \;
find /var/www/localhost/htdocs/matomo/tmp/logs/ -type d -exec chmod 755 {} \;
find /var/www/localhost/htdocs/matomo/tmp/tcpdf/ -type f -exec chmod 644 {} \;
find /var/www/localhost/htdocs/matomo/tmp/tcpdf/ -type d -exec chmod 755 {} \;
find /var/www/localhost/htdocs/matomo/tmp/templates_c -type f -exec chmod 644 {} \;
find /var/www/localhost/htdocs/matomo/tmp/templates_c -type d -exec chmod 755 {} \;

Install By Copy And Paste

mysql -e "drop datababse matomo"
mysql -e "create database matomo;"
mysql -e "create user wuseman@localhost identified by 'odemnn';"
mysql -e "grant all privileges on matomo.* to wuseman@localhost;"
mysql -e "flush privileges;"
wget https://builds.matomo.org/matomo-latest.zip
unzip matomo-latest.zip -d /var/www/html/site
chown wuseman:wuseman /var/www/html/site -R
google-chrome-stable http://localhost/matomo

Upgrade matomo

php /var/www/localhost/htdocs/matomo/console core:update

  • Comments are closed on this article!

Last update: December 7, 2022 03:36:36