Hoe Matomo op CentOS 7 Nginx te installeren

Hoe Matomo op CentOS 7 Nginx te installeren

In dit artikel leren we hoe je Matomo installeert op CentOS 7 Nginx.

Matomo, voorheen Piwik, is een gratis en open source webanalyse-applicatie ontwikkeld door een team van internationale ontwikkelaars, die draait op een PHP/MySQL-webserver. Het houdt online bezoeken aan een of meer websites bij en geeft rapporten over deze bezoeken weer voor analyse.

Waarom Matomo

Analytics-gegevens zijn van u. Uw Matomo Analytics-gegevens zijn 100% van u, zonder dat externe partijen naar binnen kijken.

In tegenstelling tot Google Analytics, dat uw gegevens gebruikt om zijn advertentieplatform te bedienen, kunnen Matomo-gebruikers veilig analyses gebruiken zonder zich zorgen te maken dat gegevens worden gebruikt voor marketing of andere doeleinden.

Vereisten:

Voordat u aan de slag gaat, moet u ervoor zorgen dat u over het volgende beschikt:

  • Een VPS of dedicated server.
  • Een besturingssysteem met CentOS 7
  • Toegang tot uw webserver (via shell of FTP)

1. Eerste stappen

Houd uw server up-to-date:

# yum update -y

2. Installeer MariaDB 10.4 en maak een database voor Matomo

Maak het MariaDB.repo-bestand in je favoriete editor:

# vi /etc/yum.repos.d/MariaDB.repo

En voeg de volgende regels toe:

# MariaDB 10.4 CentOS repository list
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]

name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Start nu de installatie van de MariaDB 10.4

# yum install MariaDB-client MariaDB-server

Nadat het klaar is, start u MariaDB:

# systemctl start mariadb.service

# systemctl enable mariadb.service

Beveilig de MySQL

# mysql_secure_installation

2. Installeer Nginx

Voeg EPEL (Extra Packages for Enterprise Linux) repository toe:

# yum install epel-release

Installeer nu NGINX met de volgende opdracht:

# yum install nginx

Start en schakel de Nginx-service in

# systemctl start nginx

# systemctl enable nginx

Nginx configureren voor Matomo

# vi /etc/nginx/conf.d/matomo.conf

Voeg de volgende configuratieregels toe:

server {

listen [::]:80;
listen 80;

server_name example.com;
root /var/www/matomo/;
index index.php;

location ~ ^/(index|matomo|piwik|js/index).php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param HTTP_PROXY "';
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
}

location = /plugins/HeatmapSessionRecording/configs.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $fastcgi_script_name =404;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param HTTP_PROXY "';
fastcgi_pass unix:/var/run/php-fpm/php-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;
}

}

Maak je voorlopig geen zorgen over SSL-omleiding. We zullen Let's Encrypt later in dit artikel installeren met Certbot. Certbot voegt automatisch SSL-omleiding en certificaatlocatie toe tijdens het verkrijgen van het certificaat.

Test de configuratie

# nginx -t

Als de test succesvol is, start u de Nginx-service opnieuw. Als de test mislukt, controleer dan de fout en pas het configuratiebestand aan volgens de vereisten.

# systemctl restart nginx

3. Installeer PHP met PHP-FPM voor Nginx

Installeer Remi-repository:

# rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

PHP-versie inschakelen:

# yum-config-manager --enable remi-php73

Installeer nu PHP 7.3 samen met de vereiste PHP-modules:

# yum -y install php php-fpm php-common php-mysqlnd php-gd  php-json php-libxml php-mbstring php-xml php-curl php-fileinfo  php-mcrypt php-memcached php-imagick

Open het php-fpm-configuratiebestand:

# vi /etc/php-fpm.d/www.conf

Zoek naar gebruiker en groep, verander de parameter in nginx van apache.

user = nginx

group = nginx

Zoek de luisterparameter en wijzig deze als volgt:

listen = /var/run/php-fpm/php-fpm.sock

Zoek regels die de listen.owner en listen.group instellen en verwijder de opmerkingen. Stel in op nginx:

listen.owner = nginx

listen.group = nginx

Nadat u de configuratie hebt voltooid, slaat u op en sluit u af.

Start nu en schakel de PHP-processor in:

# systemctl start php-fpm

# systemctl enable php-fpm

4. Installeer Let's Encrypt met Certbot

Installeer het certbot-nginx-pakket:

# yum install certbot-nginx -y

Een certificaat behalen

# certbot --nginx -d yoursite.com -d www.yousite.com

5. Installeer Matomo Analytics

Navigeer naar /var/www map

# cd /var/www/

Download de nieuwste release Matomo met behulp van het wget- commando en pak het uit

# wget https://builds.matomo.org/matomo.zip && unzip matomo.zip

Verwijder het gedownloade matomo.zip-bestand

# rm -rf matomo.zip

Wijzig het eigendom van de map /var/www/matomo naar nginx- gebruiker

# chown -R nginx:nginx /var/www/matomo

6. Voltooi de Matomo Analytics

Open uw website in de browser en volg de Matomo webinstallatiewizard.

Tijd om aan de slag te gaan met de point-and-click installatie! Klik volgende "

Hoe Matomo op CentOS 7 Nginx te installeren

We hebben met succes geleerd hoe we Matomo op CentOS 7 Nginx kunnen installeren.