GNU/Linux >> Tutoriels Linux >  >> Ubuntu

Comment installer Matomo Web Analytics sur Ubuntu 20.04

Matomo, anciennement connu sous le nom de Piwik, est une application d'analyse Web gratuite et open source qui vous aide à suivre les visiteurs en ligne sur votre site Web. Il s'agit d'une alternative au logiciel Google Analytics qui vous donne le contrôle total de vos propres analyses et données de site Web sans utiliser de solutions tierces. Il est conçu pour les petites et moyennes entreprises et peut être utilisé pour suivre les indicateurs de performance clés tels que les visites, les téléchargements, les taux de conversion par objectif, les mots clés et bien d'autres.

Dans ce tutoriel, nous allons vous montrer comment installer le logiciel d'analyse Web Matomo sur Ubuntu 20.04 avec Nginx et Let's Encrypt SSL.

Prérequis

  • Un serveur exécutant Ubuntu 20.04.
  • Un nom de domaine valide pointé vers l'adresse IP de votre serveur.
  • Un mot de passe root est configuré sur le serveur.

Mise en route

Tout d'abord, il est recommandé de mettre à jour vos packages système avec la dernière version. Vous pouvez les mettre à jour en exécutant la commande suivante :

apt-get update -y

Une fois tous les packages mis à jour, installez les autres dépendances requises en exécutant la commande suivante :

apt-get install curl wget vim git unzip socat gnupg2 -y

Après avoir installé tous les packages requis, vous pouvez passer à l'étape suivante.

Installer le serveur LEMP

Matomo fonctionne sur un serveur Web, écrit en PHP et utilise MySQL pour la base de données. La pile LEMP doit donc être installée sur votre serveur. Vous pouvez l'installer avec la commande suivante :

apt-get install nginx mariadb-server php7.4 php7.4-cli php7.4-fpm php7.4-common php7.4-curl php7.4-gd php7.4-xml php7.4-mbstring php7.4-mysql -y

Une fois la pile LEMP installée, vous pouvez passer à l'étape suivante.

Créer une base de données Matomo

Matomo nécessite une base de données pour stocker les données d'analyse. Vous devrez donc créer une base de données et un utilisateur pour Matomo.

Tout d'abord, connectez-vous à MariaDB avec la commande suivante :

mysql

Après la connexion, créez une base de données et un utilisateur pour Matomo avec la commande suivante :

MariaDB [(none)]> CREATE DATABASE matomodb;
MariaDB [(none)]> GRANT ALL ON matomodb.* TO 'matomo' IDENTIFIED BY 'password';

Ensuite, videz les privilèges et quittez MariaDB avec la commande suivante :

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Une fois votre base de données créée, vous pouvez passer à l'étape suivante.

Télécharger Matomo

Tout d'abord, téléchargez la dernière version de Matomo dans le répertoire racine Web de Nginx à partir de son site Web officiel avec la commande suivante :

cd /var/www/html/
wget https://builds.matomo.org/matomo.zip

Une fois téléchargé, décompressez le fichier téléchargé avec la commande suivante :

unzip matomo.zip

Ensuite, changez la propriété du matomo en www-data :

chown -R www-data:www-data /var/www/html/matomo

Une fois que vous avez terminé, vous pouvez passer à l'étape suivante.

Configurer Nginx pour Matomo

Ensuite, vous devrez créer un nouveau fichier de configuration d'hôte virtuel Nginx pour servir Matomo.

nano /etc/nginx/sites-available/matomo.conf

Ajoutez les lignes suivantes :

server {

  listen 80;
  server_name matomo.linuxbuz.com;
  root /var/www/html/matomo/;
  index index.php;

  location ~ ^/(index|matomo|piwik|js/index).php {
    include snippets/fastcgi-php.conf;
    fastcgi_param HTTP_PROXY ""; 
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; 
  }
  
  location = /plugins/HeatmapSessionRecording/configs.php {
    include snippets/fastcgi-php.conf;
    fastcgi_param HTTP_PROXY "";
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  }

  location ~* ^.+\.php$ {
    deny all;
    return 403;
  }

  location / {
    try_files $uri $uri/ =404;
  }
  
  location ~ /(config|tmp|core|lang) {
    deny all;
    return 403;
  }

  location ~ \.(gif|ico|jpg|png|svg|js|css|htm|html|mp3|mp4|wav|ogg|avi|ttf|eot|woff|woff2|json)$ {
    allow all;
  }

  location ~ /(libs|vendor|plugins|misc/user) {
    deny all;
    return 403;
  }

}

Enregistrez et fermez le fichier puis activez l'hôte virtuel avec la commande suivante :

ln -s /etc/nginx/sites-available/matomo.conf /etc/nginx/sites-enabled/

Ensuite, vérifiez le Nginx pour toute erreur de configuration avec la commande suivante :

nginx -t

Vous devriez voir le résultat suivant :

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Enfin, redémarrez le service Nginx pour appliquer les modifications :

systemctl restart nginx

À ce stade, Nginx est configuré pour servir Matomo. Vous pouvez maintenant passer à l'étape suivante.

Sécuriser Matomo avec Let's Encrypt SSL

C'est toujours une bonne idée de sécuriser votre site Web avec Let's Encrypt SSL. Tout d'abord, installez le client Certbot Let's Encrypt sur votre serveur avec la commande suivante :

apt-get install python3-certbot-nginx -y

Une fois installé, sécurisez votre site Web avec Let's Encrypt SSL en exécutant la commande suivante :

certbot --nginx -d matomo.linuxbuz.com

Il vous sera demandé de fournir une adresse e-mail valide et d'accepter les conditions d'utilisation comme indiqué ci-dessous :

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for matomo.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/matomo.conf

Ensuite, choisissez de rediriger ou non le trafic HTTP vers HTTPS comme indiqué ci-dessous :

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Tapez 2 et appuyez sur Entrée pour terminer l'installation. Vous devriez voir le résultat suivant :

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/matomo.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://matomo.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=matomo.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/matomo.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/matomo.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-10-30. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

Maintenant, votre site Matomo est sécurisé avec Let's Encrypt SSL.

Accéder à Matomo Analytics

Maintenant, ouvrez votre navigateur Web et tapez l'URL https://matomo.linuxbuz.com. Vous serez redirigé vers l'écran d'accueil de Matomo :

Cliquez sur SUIVANT bouton. Vous devriez voir l'écran de vérification des prérequis Matomo :

Cliquez sur SUIVANT bouton. Vous devriez voir l'écran de configuration de la base de données matomo :

Fournissez les détails de votre base de données et cliquez sur SUIVANT bouton. Vous devriez voir l'écran suivant :

Cliquez sur SUIVANT bouton. Vous devriez voir l'écran de configuration de l'utilisateur administrateur :

Indiquez votre nom d'utilisateur, votre mot de passe, votre adresse e-mail et cliquez sur SUIVANT bouton. Vous devriez voir l'écran de configuration du site :

Fournissez les détails de votre site Web et cliquez sur SUIVANT bouton. Vous devriez voir l'écran suivant :

Cliquez sur SUIVANT bouton. Une fois l'installation terminée, vous devriez voir l'écran suivant :

Cliquez sur CONTINUER VERS MATOMO . Vous serez redirigé vers l'écran de connexion Matomo :

Fournissez votre nom d'utilisateur administrateur, votre mot de passe et cliquez sur CONNEXION bouton. Vous devriez voir le tableau de bord Matomo dans l'écran suivant :

Conclusion

Toutes nos félicitations! vous avez installé et configuré avec succès Matomo Analytics avec Nginx et Let's Encrypt sur Ubuntu 20.04. Vous pouvez maintenant intégrer votre site Web à Matomo et commencer à suivre votre site Web. N'hésitez pas à me demander si vous avez des questions.


Ubuntu
  1. Comment installer le navigateur Web Chromium sur Ubuntu 18.04

  2. Comment installer Matomo Web Analytics sur Debian 9

  3. Comment installer Logstash sur Ubuntu 18.04

  4. Comment installer Matomo Web Analytics sur Ubuntu 20.04

  5. Comment installer R sur Ubuntu 18.04

Comment installer Podman sur Ubuntu 20.04

Comment installer Matomo Web Analytics sur Ubuntu 18.04 LTS

Comment installer OpenCV sur Ubuntu 20.04

Comment installer Sysdig sur Ubuntu 20.04

Comment installer Open Web Analytics sur Ubuntu 18.04 LTS

Comment installer la plateforme d'analyse Web Matomo sur Ubuntu Server 20.04