zoukankan      html  css  js  c++  java
  • Matomo搭建一个属于自己的网站统计分析站点

    本文介绍matomo(前身Pwiki)的本地搭建过程。matomo作为前端页面的日志统计工具,对一些网站的监控还是很有必要的。 

    参考官网的安装步骤,其中至少需要:

    1. 数据库(选用 mysql 5.7.24)

    2. nginx代理 (选用 nginx 1.6.3)

    3. php (选用 php 7.2.12)

    主机 IP地址 服务
    web01 10.0.0.7 wordpress
    web02 10.0.0.8 matomo

    部署WEB环境安装Matomo程序

    安装nginx,搭建web页面

    vim /etc/yum.repos.d/nginx.repo    --官方源
    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    
    [root@web01 ~]# yum install nginx -y 

    编辑/etc/nginx/conf.d/blog.conf配置文件

     server {
            listen       80;
            server_name  blog.oldboy.com;
        client_max_body_size 100m;
            location / {
                root   /html;
                index  index.php  index.html index.htm;
            }
            location ~ .php$ {
                root /html;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
            }
        }

    创建目录/html

    [root@web01 ~]# mkdir /html
    [root@web01 ~]# cd /html
    [root@web01 /html]# wget https://builds.matomo.org/matomo.zip   --下载matomo
    [root@web01 /html]# unzip matomo-latest.zip
    [root@web01 /html]# mv matomo/* /html/       --将文件移动到/html
    [root@web01 /html]# chown -R nginx.nginx .

    安装php

    网盘链接https://pan.baidu.com/s/1l67P0Y4GY_8AHhKXp8mgSQ 提取码:7vmw

    解压php71w.tar.gz并安装php (php链接地址在上面查找)

    [root@web01 ~]# ls 
    a  anaconda-ks.cfg  php71w.tar.gz
    [root@web01 ~]# cd /a
    [root@web01 ~/a]# yum localinstall ./*.rpm -y 
    [root@web01 ~/a]# vim /etc/php-fpm.d/www.conf 
    -- 修改所属主和所属组为nginx
    [root@web01 ~/a]# systemctl start php-fpm 
    [root@web01 ~/a]# systemctl enable  php-fpm 

    部署mariadb

    yum install mariadb mariadb-server -y
    systemctl start mariadb
    systemctl enable mariadb
     
    mysql
    #创建matomo数据库
    MariaDB [(none)]> create database matomo;
    MariaDB [(none)]> grant all on matomo.* to matomo@'10.0.0.%' identified by '123456';

    下载matomo

    官网地址https://matomo.org/

    [root@web01 ~]# mkdir /html
    [root@web01 ~]# cd /html
    [root@web01 /html]# wget https://builds.matomo.org/matomo.zip 
    --解压文件
    [root@web01 /html]# chown  -R nginx.nginx .

    登录地址http://10.0.0.7/index.php

     

    安装说明在/html删除文件

    rm "/html/How to install Matomo.html" "/html/matomo-latest.zip"

    设置要统计的网站

    将网站js代码复制下来  注:代码唯一

    创建wordpress网站

    wordpress官网https://wordpress.org/

    网盘链接https://pan.baidu.com/s/1F59vA1Ux9vh0SqL2x19LUg 提取码:f5oe

    安装nginx

    vim /etc/yum.repos.d/nginx.repo    --官方源
    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    
    [root@web01 ~]# yum install nginx -y 

    编辑/etc/nginx/conf.d/blog.conf配置文件

     server {
            listen       80;
            server_name  10.0.0.8;
        client_max_body_size 100m;
            location / {
                root   /html;
                index  index.php  index.html index.htm;
            }
            location ~ .php$ {
                root /html;
                fastcgi_pass  127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
            }
        }

    安装php

    #安装php71w.tar.gz
    [root@web02 ~/a]# yum localinstall ./*.rpm -y
    
    systemctl start php-fpm 
    systemctl enable php-fpm

    部署mariadb

    yum install mariadb mariadb-server -y
    systemctl start mariadb
    systemctl enable mariadb
    mysql

    创建blog数据库

    MariaDB [(none)]> create database blog;
    MariaDB [(none)]> grant all on blog.* to blog@'10.0.0.%' identified by '123456';

    wordpress文件

    [root@web02 /html]# unzip wordpress-5.3-zh_CN.zip 
    [root@web02 /html]# mv ./wordpress/* /html/ 
    [root@web02 /html]# chown -R nginx.nginx .
    [root@web02 /html]# systemctl restart nginx

    登录:10.0.0.8/index.php

    在站点目录创建wp-config.php

    matomo统计代码加入到网站

    [root@web02 /html/wp-content/themes/twentyseventeen]# vim footer.php 
    --将代码放入</body>上面

    登录matomohttp://10.0.0.7/index.php需要刷新

  • 相关阅读:
    单调栈
    ROS 运行Python程序报错:ERROR: cannot launch node of type [teleop/teleop_key]: can't locate node [teleop_key] in package [teleop]
    c++ dynamic_cast 笔记
    C++ STL map 随手笔记
    TDD 中关于mock一些理解
    C++ struct 初始化的问题
    C++ count_if/erase/remove_if 用法详解
    C++ 编译报错discards qualifiers [-fpermissive]
    笔记本外接显示器没有声音
    virtual box ubuntu 主机和虚拟机实现互相复制粘贴
  • 原文地址:https://www.cnblogs.com/Mercury-linux/p/12273866.html
Copyright © 2011-2022 走看看