• Centos 7.5 系统安装 matomo环境搭建,建立网站统计分析站点


    配置要求:

    安装前环境检查

    1. Matomo要求PHP版本高于PHP5.5(选用PHP7.2)
    2. Matomo需要pdo和pdo_mysql或mysqli支持(选用mysqli)
    3. Matomo要求Mysql版本高于MySQL5.5或者使用MariaDB(选用MySQL5.7)
    4. Matomo要求Nginx或Apache或IIS做服务器 (选用Nginx)

     一:OS 准备, 这里我安装的centos 7.5 ,不带GUI。

    1 [root@orc2 ~]# cat /etc/*release
    2 CentOS Linux release 7.5.1804 (Core) 
    3 NAME="CentOS Linux"
    4 VERSION="7 (Core)"
    5 ID="centos"

    二:工具准备

    1 [root@orc2 ~]# sudo yum install -y wget curl vim zip unzip bash-completion #安装相关工具
    2 [root@orc2 ~]# setenforce 0 #禁用SELinux
    3 setenforce: SELinux is disabled
    4 [root@orc2 ~]# systemctl stop firewalld #停止防火墙
    5 [root@orc2 ~]# systemctl disable firewalld #禁用防火墙开机自启

    三:安装mysql 数据库

       

        安装配置过程参见:https://www.cnblogs.com/vmsky/p/13754762.html

      因安装php需要,安装过程需要补充安装:mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm

       1 [root@orc2 mysql]# rpm -Uvh mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm 

    四:开始安装PHP7.2

    linux的yum源不存在php7.x,所以要更改yum源

    1 rpm  -Uvh   https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    2 rpm  -Uvh   https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    3 yum  -y  install  php72w-cli  php72w-common  php72w-devel php-mysqli php72w-fpm php72w php72w-cli php72w-fpm php72w-curl php72w-gd php72w-mysql php72w-xml php72w-mbstring
    4 yum  install  yum-utils –y

     检查 PHP version.

    1 [root@orc2 mysql]# php --version
    2 PHP 7.2.32 (cli) (built: Aug 23 2020 18:46:58) ( NTS )
    3 Copyright (c) 1997-2018 The PHP Group
    4 Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    5 [root@orc2 mysql]# 

     设置服务开机自动启动并启动服务

    1 [root@orc2 ~]# systemctl start php-fpm.service
    2 [root@orc2 ~]# systemctl enable php-fpm.service
    Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

    五、安装Matomo (有墙)

      最新版本的下载地址:https://builds.matomo.org/matomo.zip

           在安装的过程中发现新版存在bug,就使用了旧版的,下载地址:https://builds.piwik.org/piwik.zip

         

    
    
    1 [root@orc2 ~]# mkdir -p /data/ekp/matomo
    2 [root@orc2 ~]# cd /data/ekp/matomo
    3 [root@orc2 ~]# wget https://builds.piwik.org/piwik.zip && unzip piwik.zip && rm piwik.zip && mv piwik/* . && rmdir piwik

     配置PHP 的服务运行账号和组

    1 [root@orc2 /]#  vim /etc/php-fpm.d/www.conf

     重启php-fpm 服务

    1 [root@orc2 /]# systemctl restart php-fpm.service

    六:安装配置nginx (同时配置了80 和443端口访问)

      安装nginx  

    1 [root@orc2 ~]# yum install -y nginx

    Installed:
    nginx.x86_64 1:1.16.1-2.el7

    Dependency Installed:
    centos-indexhtml.noarch 0:7-9.el7.centos gperftools-libs.x86_64 0:2.6.1-1.el7 nginx-all-modules.noarch 1:1.16.1-2.el7 nginx-filesystem.noarch 1:1.16.1-2.el7 nginx-mod-http-image-filter.x86_64 1:1.16.1-2.el7
    nginx-mod-http-perl.x86_64 1:1.16.1-2.el7 nginx-mod-http-xslt-filter.x86_64 1:1.16.1-2.el7 nginx-mod-mail.x86_64 1:1.16.1-2.el7 nginx-mod-stream.x86_64 1:1.16.1-2.el7

    Complete!

    设置服务开机自动启动并启动服务

    1 [root@orc2 ~]# systemctl enable nginx.service
    2 Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /u
    3 [root@orc2 ~]# systemctl start nginx.service
    4 [root@orc2 ~]# 

    配置Nginx 服务

    1 [root@orc2 /]# vim /etc/nginx/nginx.conf

    配置根目录指向

     

    server {
            listen       80 default_server;
            listen       [::]:80 default_server;
            server_name  _;
            #root         /usr/share/nginx/html;
            root         /data/ekp/matomo;
    
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            location / {
    
                    try_files $uri /index.php$is_args$args;
            }
    
    
            location ~ .php$ {
                    try_files $uri =404;
                    include fastcgi_params;
                    fastcgi_pass 127.0.0.1:9000;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

    启用8443 端口:

    在该文件后面新增如下配置项。

      

    server {
           listen       8443 ssl http2 default_server;
           listen       [::]:8443 ssl http2 default_server;
           server_name  _;
           root        /data/ekp/matomo;
    
           ssl_certificate "/data/ekp/cert/aactechnologies.com.crt";
           ssl_certificate_key "/data/ekp/cert/aactechnologies.com.key";
           ssl_session_cache shared:SSL:1m;
           ssl_session_timeout  10m;
           ssl_ciphers HIGH:!aNULL:!MD5;
           ssl_prefer_server_ciphers on;
    
           # Load configuration files for the default server block.
           include /etc/nginx/default.d/*.conf;
    
           location / {
    
                    try_files $uri /index.php$is_args$args;
            }
    
    
            location ~ .php$ {
                    try_files $uri =404;
                    include fastcgi_params;
                    fastcgi_pass 127.0.0.1:9000;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    
           error_page 404 /404.html;
               location = /40x.html {
           }
    
           error_page 500 502 503 504 /50x.html;
               location = /50x.html {
           }
       }
    

      测试Nginx 配置可用性

    1 [root@orc2 /]# nginx -t
    2 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    3 nginx: configuration file /etc/nginx/nginx.conf test is successful

    重启nginx 是配置生效。

    1 [root@orc2 /]# sudo systemctl reload nginx.service
    2 [root@orc2 /]# 

    七、访问测试

      初始化配置过程参见链接:https://matomo.org/docs/installation/

      严重报错要全部解决。

      追踪代码

      

    <!-- Matomo -->
    <script type="text/javascript">
      var _paq = window._paq = window._paq || [];
      /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
      _paq.push(['trackPageView']);
      _paq.push(['enableLinkTracking']);
      (function() {
        var u="//https://matomo.aactechnologies.com:8011/";
        _paq.push(['setTrackerUrl', u+'matomo.php']);
        _paq.push(['setSiteId', '1']);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
      })();
    </script>
    <!-- End Matomo Code -->

    效果图

      

     

    参考文档:

    1、https://www.vultr.com/docs/how-to-install-matomo-analytics-on-centos-7

    2、mysql 安装配置:https://www.cnblogs.com/qjoanven/p/7699382.html

    3、nginx 安装配置:https://www.runoob.com/linux/nginx-install-setup.html

  • 相关阅读:
    EDR绕过方法
    UACBypass COM提权学习
    远程注入BOF
    windows server 2012 R2 部署AD域服务
    Impacket使用
    计划任务.Job文件的格式
    使用MicrosoftWindowsRPC监控横向渗透
    使用wazuh搭建安全监控平台
    C# 在datagridview 控件中关联DATASET 后添加空行的
    C# 从EXCEL导入数据到数据库,动态绑定列名( 第一次作业)
  • 原文地址:https://www.cnblogs.com/vmsky/p/13772708.html
Copyright © 2020-2023  润新知