Matomo build environment to build, creating a website statistical analysis of site

    Matomo user behavior statistics are a tool of the front page, with PHP language. As a Java developer, to build a PHP environment has a lot of dead brain cells. To this end, here to do a record, but also to others. Matomo official website: https://matomo.org/ .

 First, the need to:

  1、Nginx:1.6.1
  2、PHP:7.1
  3、mysql:5.7.25

  4, Matomo, foreign download site is too slow, if I here, here to provide a Baidu network disk:

    Link: https: //pan.baidu.com/s/1Q2EtGcC2Qg2kIUrM9sGZAw
    extraction code: ldm5 

  5, Centos7 operating system

  Nginx above, mysql installation will not say my side, giving me a headache emphasis record of PHP and nginx configuration.

Two, PHP installation

  1, will be replaced yum warehouse pack upgrade the rpm package PHP7:

    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

  2, view the version information
    sudo yum search php71w


  3, installation and extension php

    sudo yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath

  4, open service
    ①, sudo service php-fpm start ( but this way will start permission issues)

    ②、sudo php-fpm -R

  These are the PHP environment to build, to speak truth, I really did not know what to do above. Follow the steps just fine. And then there's the most important thing is to modify the php-fpm services Matomo owners , such as my nginx Matomo the user and the owner is admin. This let me in here took a lot of authority, as follows :( remember to restart php-fpm Service)

    sudo came /etc/php-fpm.d/www.conf

      

  Three, Nginx configuration access php
    In fact, this will have in nginx default configuration file, but it is commented:

    

    If you open the Notes can be accessed by normal php file that's great, but I was not OK, but I deployed a test environment, a formal environment, configure the two are not the same! ! ! !

     FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, are quoted on it.
    So for Baidu Development:

    One solution:

    The above configuration

      fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

    Read:

      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    Because the set is said to be the root cause of setting up in location, this configuration solves the problem on my production.

    The second option:

      In this location in the last line:

      include        fastcgi.conf;

    This solves the problem of the test environment. (Probably because of the small version of nginx problem, or nginx source is not the same, there are some nginx fastcgi.conf this document, some do not)

    to restart nginx, php on the root access should be on it,
    the rest of the configuration is to visit matomo static files directly in the production of my configuration:

    location / {

      root    /home/admin/matomo

    }

    Because nobody public nginx, so unscrupulous. (All the files Matomo put under matomo)

    People use the zai test environment, it was nothing, but a one configuration
     

    location ~ (\.md|piwik\.js|matomo\.js|console|LEGALNOTICE|LICENSE)$ {
      root /home/admin/matomo;
    }


    location ^~ /plugins/ {
      root /home/admin/matomo;
    }

    location ^~ /config/ {
      root /home/admin/matomo;
    }
    location ^~ /core/ {
      root /home/admin/matomo;
    }
    location ^~ /js/ {
      root /home/admin/matomo;
    }
    location ^~ /lang/ {
      root /home/admin/matomo;
    }
    location ^~ /libs/ {
      root /home/admin/matomo;
    }
    location ^~ /misc/ {
      root /home/admin/matomo;
    }
    location ^~ /tests/ {
      root /home/admin/matomo;
    }
    location ^~ /tmp/ {
      root /home/admin/matomo;
    }
    location ^~ /vendor/ {
      root /home/admin/matomo;
    }

  The final step is the user profile is set to the corresponding user, for example, I set amdin, if nobody is there will be no access. Because it is so common to the test environment is set to root, but also a problem: nginx download a static file will be created when the cache, as the attribution of this cache files with which the user is not necessarily my permission problems with the admin time, but later found some when the cache belonging to root sometimes attributed to the admin, appearance did not have permission to access.

  So far nginx configuration is complete, well, then you can see when you first log into the configuration interface

Third, the configuration Matomo:

   First you need to configure the configuration data, to build a database Matomo used in mysql. (Screenshot here, but very simple, follow the prompts to be completed)

Summary: 1, most are not familiar with php let me heartburn.
   2, linux and rights issues are also important in the production configuration of php when normal access files, static files can not access life and death, but later found SELinux set to ON state (enabled) causes production.
    View the status of current selinux:

    ①、/usr/sbin/sestatus,②、getenforce 
    解决方案

    ①, setenforce 0, turn off selinux, which temporarily shut down, restart the server after failure

    ②、vim /etc/selinux/config,将SELINUX=enforcing改为SELINUX=disabled,永久关闭,但是得重启服务器。

   3, leaders said Matomo some content he does not need, no need, let me go and change PHP source code, I Nima!


 

 

Guess you like

Origin www.cnblogs.com/lwxiao/p/12466370.html