웹사이트 검색

Fedora 29에 Matomo Web Analytics를 설치하는 방법


이 페이지에서

  1. 요구 사항\n
  2. 전제 조건
  3. 초기 단계
  4. 1단계 - MariaDB를 설치하고 Matomo용 데이터베이스 만들기\n
  5. 2단계 - PHP 및 필요한 PHP 확장 설치\n
  6. 3단계 - acme.sh 클라이언트 설치 및 Let\>)
  7. 3단계 - NGINX 설치 및 Matomo용 NGINX 구성
  8. 4단계 - Matomo Analytics 설치
  9. 5단계 - Matomo Analytics 설정 완료
  10. 링크

Matomo(이전 Piwik) 는 PHP/MySQL 웹 서버에서 실행되는 국제적인 개발자 팀이 개발한 무료 오픈소스 웹 분석 애플리케이션입니다. 하나 이상의 웹사이트에 대한 온라인 방문을 추적하고 분석을 위해 이러한 방문에 대한 보고서를 표시합니다. 구글 애널리틱스의 대안이라고 생각하시면 됩니다. Matomo는 오픈소스이며 해당 코드는 Github에서 공개적으로 사용할 수 있습니다. A/B 테스트, 히트맵, 퍼널, 추적 및 보고 API, Google 애드워즈, Facebook 광고, Bing 광고, CPC(클릭당 비용) 등의 기능이 있습니다. 이 자습서에서는 Matomo를 설치하는 방법을 보여줍니다. Nginx를 웹 서버로 사용하는 Fedora 29 시스템이며 Lets Encrypt SSL 인증서로 웹사이트를 보호합니다.

요구 사항

Fedora 29 시스템에서 Matomo(Piwik)를 실행하려면 몇 가지가 필요합니다.

  • Apache, Nginx, IIS와 같은 웹 서버.
  • pdo 및 pdo_mysql 또는 mysqli, gd, xml, curl 및 mbsting 확장 프로그램이 있는 PHP 버전 5.5.9 이상. PHP 7+를 권장합니다.\n
  • MySQL 버전 5.5 이상 또는 동등한 MariaDB 버전. MySQL 5.7+가 권장됩니다.

전제 조건

  • Fedora 29를 실행하는 운영체제입니다.\n
  • sudo 권한이 있는 루트가 아닌 사용자.\n

초기 단계

Fedora 버전 확인:

cat /etc/fedora-release
# Fedora release 29 (Twenty Nine)

시간대 설정:

timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'

운영 체제 패키지(소프트웨어)를 업데이트합니다. 이는 운영 체제 기본 소프트웨어 패키지에 대한 최신 업데이트 및 보안 수정 사항이 있는지 확인하기 때문에 중요한 첫 번째 단계입니다.

sudo dnf check-update; sudo dnf update -y

Fedora 운영체제의 기본 관리에 필요한 몇 가지 필수 패키지를 설치합니다.

sudo dnf install -y curl wget vim git unzip socat

1단계 - MariaDB를 설치하고 Matomo용 데이터베이스 만들기

Matomo는 MySQL 및 MariaDB 데이터베이스를 지원합니다. 이 튜토리얼에서는 MariaDB를 데이터베이스 서버로 사용합니다.

MariaDB 데이터베이스 서버를 설치합니다.

sudo dnf install -y mariadb-server

MariaDB 버전을 확인합니다.

mysql --version
# mysql  Ver 15.1 Distrib 10.3.11-MariaDB, for Linux (x86_64) using readline 5.1

MariaDB 서비스 시작 및 활성화:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

mysql_secure 설치 스크립트를 실행하여 MariaDB 보안을 개선하고 MariaDB 루트 사용자의 비밀번호를 설정합니다.

sudo mysql_secure_installation

각 질문에 답하십시오.

Would you like to setup VALIDATE PASSWORD plugin? N
New password: your_secure_password
Re-enter new password: your_secure_password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

루트 사용자로 MariaDB 셸에 연결합니다.

sudo mysql -u root -p
# Enter password

빈 MariaDB 데이터베이스와 Matomo 사용자를 만들고 사용자 인증 정보를 기억하세요.

MariaDB> CREATE DATABASE dbname;
MariaDB> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
MariaDB> FLUSH PRIVILEGES;

MariaDB에서 종료:

mysql> exit

dbname, usernamepassword를 자신의 이름으로 바꾸세요.

2단계 - PHP 및 필요한 PHP 확장 설치

PHP와 필요한 PHP 확장을 설치합니다.

sudo dnf install -y php php-cli php-fpm php-common php-curl php-gd php-xml php-mbstring php-mysqlnd php-json

PHP 버전 확인:

php --version

# PHP 7.2.14 (cli) (built: Jan  8 2019 09:59:17) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

PHP-FPM 서비스 시작 및 사용:

sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service

Lets Encrypt CA에서 무료 SSL 인증서를 받는 다음 단계로 넘어갈 수 있습니다.

3단계 - acme.sh 클라이언트 설치 및 Lets Encrypt 인증서 받기(선택사항)

HTTPS로 웹 사이트를 보호할 필요는 없지만 사이트 트래픽을 보호하는 것이 좋습니다. Lets Encrypt에서 TLS 인증서를 얻기 위해 Acme.sh 클라이언트를 사용합니다. Acme.sh는 종속성이 없는 Lets Encrypt에서 TLS 인증서를 얻기 위한 순수 UNIX 셸 소프트웨어입니다.

Acme.sh 다운로드 및 설치:

sudo mkdir /etc/letsencrypt
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh 
sudo ./acme.sh --install --home /etc/letsencrypt --accountemail 
cd ~

Acme.sh 버전 확인:

/etc/letsencrypt/acme.sh --version
# v2.8.0

도메인/호스트 이름에 대한 RSA 및 ECC/ECDSA 인증서 받기:<br>

# RSA 2048
sudo /etc/letsencrypt/acme.sh --issue --standalone --home /etc/letsencrypt -d example.com --keylength 2048
# ECDSA
sudo /etc/letsencrypt/acme.sh --issue --standalone --home /etc/letsencrypt -d example.com --keylength ec-256

위 명령어를 실행하면 인증서가 다음 위치에 있게 됩니다.

  • RSA의 경우: /etc/letsencrypt/example.com 디렉토리.
  • ECC/ECDSA의 경우: /etc/letsencrypt/example.com_ecc 디렉토리.

3단계 - NGINX 설치 및 Matomo용 NGINX 구성

Matomo는 널리 사용되는 여러 웹 서버 소프트웨어와 잘 작동합니다. 이 튜토리얼에서는 Nginx를 선택했습니다.

Fedora 저장소에서 Nginx를 다운로드하고 설치합니다.

sudo dnf install -y nginx

Nginx 버전 확인:

sudo nginx -v
# nginx version: nginx/1.14.1

Nginx 서비스 시작 및 사용 설정:

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

다음을 실행하여 Matomo용 Nginx를 구성합니다.

sudo vim /etc/nginx/conf.d/matomo.conf

그리고 다음 구성으로 파일을 채웁니다.

server {

listen [::]:443 ssl http2;
listen 443 ssl http2;
listen [::]:80;
listen 80;

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

ssl_certificate /etc/letsencrypt/example.com/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/example.com/example.com.key;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/example.com.key;

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:/run/php-fpm/www.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:/run/php-fpm/www.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;
}

}

참고: Matomo에 대한 완전한 프로덕션 준비 Nginx 구성을 보려면 https://github.com/matomo-org/matomo-nginx를 방문하세요.

구문 오류에 대한 Nginx 구성을 확인하십시오.

sudo nginx -t

Nginx 서비스 다시 로드:

sudo systemctl reload nginx.service

4단계 - Matomo Analytics 설치

/var/www 디렉토리 만들기:

sudo mkdir -p /var/www/

/var/www 디렉토리로 이동합니다.

cd /var/www/

wget을 통해 최신 릴리스 Matomo를 다운로드하고 압축을 풉니다.

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

다운로드한 matomo.zip 파일을 제거합니다.

sudo rm matomo.zip

/var/www/matomo 디렉토리의 소유권을 nginx user:로 변경합니다.

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

sudo vim /etc/php-fpm.d/www.conf를 실행하고 사용자 및 그룹을 nginx로 설정합니다. 처음에는 사용자 및 그룹 apache로 설정됩니다.

sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx

PHP-FPM 서비스를 다시 시작하십시오.

sudo systemctl restart php-fpm.service

5단계 - Matomo Analytics 설정 완료

웹 브라우저에서 사이트를 열고 Matomo 웹 설치 마법사를 따릅니다.

먼저 Matomo 환영 메시지가 나타납니다. "다음" 버튼을 클릭합니다.

그런 다음 "시스템 확인" 페이지가 표시됩니다. 빠진 것이 있으면 경고가 표시됩니다. 모든 항목이 녹색 체크 표시로 표시되면 "다음" 버튼을 클릭하여 다음 단계로 진행합니다.

그런 다음 데이터베이스 세부정보를 입력하고 "다음" 버튼을 클릭합니다.

데이터베이스 설정에 모든 것이 순조롭게 진행되면 "Tables created with successful!" 메시지가 표시됩니다.

Matomo 슈퍼 사용자 계정을 만들고 "다음" 버튼을 클릭합니다.

다음으로 Matomo로 추적하고 분석할 첫 번째 웹사이트를 설정합니다. 나중에 Matomo로 추적할 사이트를 더 추가할 수 있습니다.

다음으로 추적을 시작하기 위해 추가해야 하는 사이트의 JavaScript 추적 코드가 제공됩니다.

다음으로 Matomo 설치가 완료된 것을 볼 수 있습니다.

축하합니다! Matomo 설치가 완료되었습니다.

연결

  • https://matomo.org/
  • https://github.com/matomo-org/matomo-nginx