GNU/Linux >> Belajar Linux >  >> Debian

Cara Memasang Matomo Web Analytics di Debian 11

Matomo, sebelumnya dikenal sebagai Piwik adalah aplikasi analisis web sumber terbuka dan gratis yang dikembangkan oleh komunitas pengembang. Ini digunakan untuk melacak situs web Anda dan memberikan informasi terperinci tentang situs web Anda dan pengunjungnya, termasuk mesin pencari dan kata kunci yang mereka gunakan, bahasa yang mereka gunakan, halaman mana yang mereka sukai, file yang mereka unduh dan banyak lagi. Ini menawarkan banyak fitur termasuk, Google AdWords, Iklan Facebook, Yahoo, Pemasaran Penelusuran, API Pelacakan dan Pelaporan, dan Biaya Per Klik (BPK).

Dalam tutorial ini, saya akan menunjukkan cara menginstal Matomo di Debian 11 dengan server web Apache2 dan sertifikat SSL Let's Encrypt gratis.

Prasyarat

  • Server yang menjalankan Debian 11.
  • Nama domain valid yang ditunjukkan dengan IP server Anda.
  • Kata sandi root dikonfigurasi di server.

Instal Apache, MariaDB, dan PHP

Pertama, Anda perlu menginstal server web Apache, server database MariaDB, PHP, dan ekstensi PHP lainnya ke server Anda. Anda dapat menginstal semuanya dengan menjalankan perintah berikut:

apt-get install apache2 mariadb-server php libapache2-mod-php php-cli php-fpm php-fpm php-json php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath curl unzip -y

Setelah menginstal semua paket, mulai dan aktifkan layanan Apache dan MariaDB menggunakan perintah berikut:

systemctl start apache2 mariadb
systemctl enable apache2 mariadb

Setelah selesai, Anda dapat melanjutkan ke langkah berikutnya.

Buat Database MariaDB untuk Matomo

Matomo menggunakan MariaDB sebagai backend database. Jadi, Anda perlu membuat database dan pengguna untuk Matomo.

Pertama, login ke MariaDB dengan perintah berikut:

mysql

Setelah Anda masuk, buat database dan pengguna dengan perintah berikut:

MariaDB [(none)]> CREATE DATABASE matomodb;
MariaDB [(none)]> CREATE USER 'matomo'@'localhost' IDENTIFIED BY 'password';

Selanjutnya, berikan semua hak istimewa ke database Matomo dengan perintah berikut:

MariaDB [(none)]> GRANT ALL ON matomodb.* TO 'matomo'@'localhost' WITH GRANT OPTION;

Selanjutnya, flush hak istimewa dan keluar dari shell MariaDB dengan perintah berikut:

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

Setelah mengkonfigurasi database MariaDB, Anda dapat melanjutkan ke langkah berikutnya.

Unduh Matomo

Selanjutnya, kunjungi situs resmi Matomo dan unduh versi terbaru Matomo dengan perintah berikut:

wget http://builds.matomo.org/matomo-latest.zip

Setelah unduhan selesai, unzip file yang diunduh dengan perintah berikut:

unzip matomo-latest.zip

Selanjutnya, pindahkan direktori yang diekstrak ke direktori root web Apache:

mv matomo /var/www/html/matomo

Selanjutnya, ubah kepemilikan dan izin direktori Matomo:

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

Setelah selesai, Anda dapat melanjutkan ke langkah berikutnya.

Konfigurasi Apache untuk Matomo

Selanjutnya, Anda perlu membuat file konfigurasi virtual host Apache untuk meng-host Matomo di internet. Anda dapat membuatnya dengan perintah berikut:

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

Tambahkan baris berikut:

<VirtualHost *:80>

ServerAdmin [email protected]
ServerName matomo.example.com
DocumentRoot /var/www/html/matomo/

<Directory /var/www/html/matomo>
DirectoryIndex index.php
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

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

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

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

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

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


</VirtualHost>

Simpan dan tutup file setelah selesai kemudian aktifkan virtual host Matomo dan modul Apache rewrite dengan perintah berikut:

a2ensite matomo.conf
a2enmod rewrite

Selanjutnya, restart layanan Apache untuk menerapkan perubahan:

systemctl restart apache2

Anda juga dapat memeriksa status Apache dengan perintah berikut:

systemctl status apache2

Anda akan mendapatkan output berikut:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-03-06 06:33:24 UTC; 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 55482 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 55486 (apache2)
      Tasks: 6 (limit: 4679)
     Memory: 12.4M
        CPU: 108ms
     CGroup: /system.slice/apache2.service
             ??55486 /usr/sbin/apache2 -k start
             ??55487 /usr/sbin/apache2 -k start
             ??55488 /usr/sbin/apache2 -k start
             ??55489 /usr/sbin/apache2 -k start
             ??55490 /usr/sbin/apache2 -k start
             ??55491 /usr/sbin/apache2 -k start

Mar 06 06:33:24 debian11 systemd[1]: Starting The Apache HTTP Server...
Mar 06 06:33:24 debian11 apachectl[55485]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 209>
Mar 06 06:33:24 debian11 systemd[1]: Started The Apache HTTP Server.

Mengakses UI Web Matomo

Sekarang, buka browser web Anda dan akses antarmuka web Matomo menggunakan URL http://matomo.example.com . Anda akan diarahkan ke halaman berikut:

Klik Berikutnya tombol. Anda akan melihat halaman pemeriksaan konfigurasi PHP:

Pastikan semua konfigurasi ok lalu klik NEXT tombol. Anda akan melihat halaman penyiapan database MariaDB:

Berikan server basis data, nama pengguna, nama basis data, kata sandi Anda, lalu klik BERIKUTNYA tombol. Anda akan melihat halaman berikut:

Klik BERIKUTNYA tombol. Anda akan melihat halaman pembuatan Pengguna Super:

Berikan nama pengguna, sandi, email admin Anda, dan klik BERIKUTNYA tombol. Anda akan melihat halaman penyiapan situs web:

Berikan nama situs web Anda, URL, zona waktu, dan klik BERIKUTNYA tombol. Anda akan melihat halaman berikut:

Klik BERIKUTNYA tombol. Anda akan melihat halaman verifikasi konfigurasi:

Klik tombol LANJUTKAN KE MATOMO . Anda akan melihat halaman login Matomo:

Berikan nama pengguna, kata sandi admin Anda, dan klik tombol MASUK tombol. Anda akan melihat dasbor Matomo di halaman berikut:Anda sekarang dapat menyalin kode Pelacakan yang ditunjukkan pada gambar di atas dan menempelkannya ke setiap halaman di situs web Anda.

Amankan Matomo dengan Let's Encrypt SSL

Selanjutnya, Anda perlu menginstal klien Certbot untuk menginstal Let's Encrypt SSL untuk situs web Anda. Anda dapat menginstalnya dengan perintah berikut:

dnf install epel-release -y dnf install certbot python3-certbot-apache

Selanjutnya, dapatkan dan instal sertifikat SSL untuk domain let Anda dengan perintah berikut:

certbot --apache -d matomo.example.com

Anda akan diminta untuk memberikan alamat email Anda dan menerima persyaratan layanan:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
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. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, 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
Account registered.
Requesting a certificate for matomo.example.com
Performing the following challenges:
http-01 challenge for matomo.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/httpd/conf.d/matomo.conf
Redirecting all traffic on port 80 to ssl in /etc/httpd/conf.d/matomo.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://matomo.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Subscribe to the EFF mailing list (email: [email protected]).


IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/matomo.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/matomo.example.com/privkey.pem
   Your certificate will expire on 2022-05-09. 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"
 - 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

Kesimpulan

Selamat! Anda telah berhasil menginstal Matomo di Debian 11. Sekarang Anda dapat menambahkan kode pelacakan ke situs web Anda dan mulai memantaunya dari dasbor Matomo. Jangan ragu untuk bertanya kepada saya jika Anda memiliki pertanyaan.


Debian
  1. Cara Menginstal MariaDB 10.x di Debian 11

  2. Cara Menginstal Matomo Web Analytics di Ubuntu 20.04

  3. Cara Menginstal Fathom Analytics di Debian 11

  1. Cara Menginstal MariaDB di Debian 9

  2. Cara Menginstal Open Web Analytics di Debian 9

  3. Cara Menginstal MariaDB di Debian 11

  1. Cara Menginstal MariaDB di Debian 10

  2. Cara Menginstal Matomo Web Analytics di Debian 9

  3. Cara Memasang Matomo Web Analytics di Fedora 29