2019/05/20

How to install Matomo on Ubuntu 18.04

apt update && sudo apt upgrade -y
apt install -y curl wget git unzip

MySQL Installation
apt install -y mysql-server
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

mysql -u root -p
mysql> CREATE DATABASE dbname;
mysql> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> exit

Nginx and PHP Installation
apt install -y nginx php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-curl php7.2-gd php7.2-xml php7.2-mbstring php7.2-mysql

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

server {

  listen [::]:80;
  listen 80;

  server_name 127.0.0.1;
  root /var/www/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.2-fpm.sock;
  }
 
  location = /plugins/HeatmapSessionRecording/configs.php {
    include snippets/fastcgi-php.conf;
    fastcgi_param HTTP_PROXY "";
    fastcgi_pass unix:/var/run/php/php7.2-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;
  }

}

ln -s /etc/nginx/sites-available/matomo.conf /etc/nginx/sites-enabled
nginx -t
systemctl reload nginx.service

Matomo Analytics Installation
cd /var/www/
wget https://builds.matomo.org/matomo.zip && sudo unzip matomo.zip
chown -R www-data:www-data /var/www/matomo
Open web browser and go to 127.0.0.1 for configure matomo settings
Add your website and copy tracking code to your web page



沒有留言:

張貼留言