9、用户访问量监控
版权声明:原创作品,谢绝转载!否则将追究法律责任。 ————— 作者:kirin
13.1使用第三方统计平台
#把上面的代码复制到网站中
#每个人每个公司的网站都不一样,这个需要开发配合来做
cd /code/wordpress/wp-content/themes/coldbox
vim footer.php

#接下来看结果


#也可以使用discuz来统计

13.2使用开源的统计平台piwik
#安装环境准备
| 主机 | 统计平台 | nginx版本 | PHP版本 | mysql版本 |
|---|---|---|---|---|
| web01-10.0.0.7 | discuz | 无要求 | 无要求 | 无要求 |
| web02-10.0.0.8 | matomo | 无要求 | 7.2以上 | 5.5以上 |
#安装PHP服务、修改配置、启动
[root@web01 ~]# yum install -y php-fpm php-gd php-mysqli
[root@web01 ~]# sed -i '/^user/c user = nginx' /etc/php-fpm.d/www.conf
[root@web01 ~]# sed -i '/^group/c group = nginx' /etc/php-fpm.d/www.conf
[root@web01 ~]# egrep -n '^user|^group' /etc/php-fpm.d/www.conf
[root@web01 ~]# systemctl restart php-fpm.service
[root@web01 ~]# systemctl enable php-fpm.service
[root@web01 ~]# ps -ef |grep php-fpm
#nginx服务已经装过了,接下来去修改一下配置即可
[root@web01 ~]# vim /etc/nginx/nginx.conf
[root@web01 ~]# cat /etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name;
include fastcgi_params;
}
location = /nginx_status {
stub_status;
access_log off;
}
}
}
#检查语法并重启服务
[root@web01 ~]# nginx -t
[root@web01 ~]# systemctl restart nginx
#创建站点目录,上传代码
[root@web01 ~]# mkdir /html
[root@web01 ~]# cd /html
[root@web01 /html]# rz -E
[root@web01 /html]# unzip Discuz_X3.4_SC_UTF8_0802.zip
[root@web01 /html]# mv upload/* .
[root@web01 /html]# chown -R nginx. .
#数据库也已经装过了,接下来去创建库,授权、初始化数据库
[root@web01 ~]# mysql
MariaDB [(none)]> create database bbs;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbs |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.05 sec)
MariaDB [(none)]> grant all on bbs.* to bbs@localhost identified by '123456';
Query OK, 0 rows affected (0.04 sec)
MariaDB [(none)]> Bye
#安全初始化
[root@web01 ~]# mysql_secure_installation (先回车,在按n,然后一路y)
#接下来输入web01的地址,打开浏览器访问:10.0.0.7









#接下来在web02-10.0.0.8上安装matomo
#nginx已经了。修改配置文件即可
#安装PHP7.2或以上版本
[root@web02 ~]# yum install epel-release -y
[root@web02 ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@web02 ~]# yum install php72w-fpm php72w-gd.x86_64 php72w-bcmath.x86_64 php72w-xml.x86_64 php72w-mbstring.x86_64 php72w-ldap.x86_64 php72w-mysqlnd.x86_64 -y
[root@web02 ~]# yum install -y php72w-fpm php72w-mysqlnd php72w-gd php72w-mbstring
[root@web02 ~]# sed -i '/^user/c user = nginx' /etc/php-fpm.d/www.conf
[root@web02 ~]# sed -i '/^group/c group = nginx' /etc/php-fpm.d/www.conf
[root@web02 ~]# egrep -n '^user|^group' /etc/php-fpm.d/www.conf
[root@web02 ~]# systemctl restart php-fpm.service
[root@web02 ~]# systemctl enable php-fpm.service
[root@web02 ~]# ps -ef |grep php-fpm
[root@web01 ~]# scp -rp /etc/nginx/nginx.conf root@10.0.0.8:/etc/nginx/nginx.conf
[root@web02 ~]# cat /etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name;
include fastcgi_params;
}
location = /nginx_status {
stub_status;
access_log off;
}
}
}
[root@web02 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@web02 ~]# systemctl restart nginx
[root@web02 ~]# systemctl enable nginx
[root@web02 ~]# mkdir /html
[root@web02 ~]# cd /html
[root@web02 /html]# rz -E
[root@web02 /html]# unzip matomo-latest.zip
[root@web02 /html]# rm -rf matomo-latest.zip How\ to\ install\ Matomo.html
[root@web02 /html]# mv matomo/* .
[root@web02 /html]# chown -R nginx. .
#接下来去访问web界面 10.0.0.8


#咱们接了节省时间,在10.0.0.7上创建数据库
[root@web01 ~]# mysql
MariaDB [(none)]> create database matomo;
MariaDB [(none)]> grant all on matomo.* to matomo@'10.0.0.8' identified by '123456';
#接下来下去web界面填写对应内容







#接下来随便访问一个界面,用F12看一下

#继续安装matomo



#接下来去刷新下10.0.0.7的discuz的web界面。多刷新几次。然后返回10.0.0.8的matomo界面


本文来自博客园,作者:kirin(麒麟),转载请注明原文链接:https://www.cnblogs.com/kirin365/articles/16387109.html




浙公网安备 33010602011771号