您好,登錄后才能下訂單哦!
WordPress是一款使用PHP語言開發的博客平臺,官網https://cn.wordpress.org/
Matomo的前身是Piwik,一套基于PHP + MySQL技術構建的開源網站訪問統計系統,Matomo可以提供統計網頁瀏覽人數、訪問最多的頁面、搜索引擎關鍵詞等流量分析功能,它還采用了插件擴展及開放API架構,可以讓用戶根據自已的實際需求創建更多的功能,軟件包下載和部署文檔地址https://matomo.org/docs/installation/
一、安裝配置Nginx:
1、安裝epel源:# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-7.noarch.rpm
2、安裝Nginx:# yum -y install nginx
3、啟動Nginx:
# systemctl start nginx
# systemctl status nginx
# ss -tunlp | grep -w :80
# systemctl enable nginx
4、瀏覽器訪問:http://192.168.0.122
二、安裝配置MariaDB:
CentOS 7.7默認yum源中的MariaDB版本為5.5.64,此處安裝MariaDB 10.4版本
1、查看系統中是否已經存在MariaDB,有則刪除:
# rpm -qa | grep -i mariadb --> mariadb-libs-5.5.64-1.el7.x86_64
# yum -y remove mariadb-libs
2、配置MariaDB的yum源:
# vim /etc/yum.repos.d/MariaDB.repo
[mariadb]
name=MariaDB Repo
baseurl=http://mirrors.ustc.edu.cn/mariadb/yum/10.4/centos7-amd64/
gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
enabled=1
gpgcheck=1
3、安裝MariaDB:# yum -y install MariaDB-server
4、修改配置文件server.cnf:
# cd /etc/my.cnf.d
# mv server.cnf server.cnf.bak
# vim server.cnf
[mysqld]
port=3306
socket=/var/lib/mysql/mysql.sock
datadir=/var/lib/mysql
log-error=/var/log/mariadb.log
lower_case_table_names=1
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
symbolic-links=0
innodb_file_per_table=1
skip_name_resolve=1
slow_query_log=1
slow_query_log_file=mysql-slow.log
server_id=1
sync_binlog=1
innodb_flush_log_at_trx_commit=1
log_bin=mysql-bin
log_bin_index=mysql-bin.index
binlog_format=row
備注:默認主配置文件不是/etc/my.cnf,而是/etc/my.cnf.d/server.cnf
5、創建錯誤日志文件:
# touch /var/log/mariadb.log
# chown mysql.mysql /var/log/mariadb.log
6、啟動MariaDB:
# systemctl start mariadb.service
# systemctl status mariadb.service
# ss -tunlp | grep -w :3306
# tail -100 /var/log/mariadb.log
# tail -100 /var/log/messages
# systemctl enable mariadb.service
7、MariaDB安全配置向導:# mysql_secure_installation
8、授權用戶遠程登錄:
# mysql -uroot -p
MariaDB [(none)]> grant all on *.* to 'root'@'192.168.0.%' identified by '123456';
MariaDB [(none)]> flush privileges;
9、創建wordpress和matomo數據庫:
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> create database matomo;
10、創建新用戶,并對其賦予數據庫權限:
MariaDB [(none)]> create user 'wpuser'@'192.168.0.%' identified by '123456';
MariaDB [(none)]> grant all on wordpress.* to 'wpuser'@'192.168.0.%';
MariaDB [(none)]> create user 'mtuser'@'192.168.0.%' identified by '123456';
MariaDB [(none)]> grant all on matomo.* to 'mtuser'@'192.168.0.%';
MariaDB [(none)]> flush privileges;
三、安裝配置PHP:
1、安裝PHP:
# rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# yum -y install mod_php72w php72w-cli php72w-common php72w-devel php72w-fpm php72w-gd php72w-ldap php72w-mbstring php72w-mysqlnd php72w-opcache php72w-xml
# php -version
2、修改www.conf配置文件:
# vim /etc/php-fpm.d/www.conf
user = apache --> user = nginx
group = apache --> group = nginx
3、啟動php-fpm:
# systemctl start php-fpm.service
# systemctl status php-fpm.service
# ss -tunlp | grep 9000
# systemctl enable php-fpm.service
四、Nginx整合PHP:
1、修改nginx.conf配置文件:
# vim /etc/nginx/nginx.conf
location / {
root?? html;
index? index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass?? 127.0.0.1:9000;
fastcgi_index? index.php;
fastcgi_param? SCRIPT_FILENAME? $document_root$fastcgi_script_name;
include?????? fastcgi_params;
}
# nginx -t
# nginx -s reload
2、創建測試頁:
# vim /usr/share/nginx/html/index.php
<?php
$conn=mysqli_connect("192.168.0.122","root","123456");
if ($conn)
echo "mysqli_connect success";
else
echo "mysqli_connect failure";
mysqli_close();
phpinfo();
?>
備注:如果在新版本PHP中使用舊版本PHP的mysql_connect()函數連接MySQL,會提示“undefined function mysql_connect()”。從PHP 5.5版本開始,MySQL就不推薦使用mysql_connect()函數,屬于廢棄函數,PHP 7中已經徹底不支持,增加了mysqli_connect()函數。從某種意義上說,mysqli是mysql系統函數的增強版,更穩定、更高效、更安全,屬于面向對象,用對象的方式操作驅動MySQL數據庫。
3、瀏覽器訪問http://192.168.0.122
停止MariaDB:# systemctl stop mariadb.service
刷新頁面:
五、安裝配置WordPress:
1、解壓WordPress:# tar -xf wordpress-5.2.4-zh_CN.tar.gz -C /usr/share/nginx/html/
2、修改wp-config.php配置文件:
# cd /usr/share/nginx/html/wordpress
# cp wp-config-sample.php wp-config.php
# vim wp-config.php
3、瀏覽器訪問http://192.168.0.122/wordpress
六、安裝配置Matomo:
1、解壓Matomo:
# yum -y install unzip
# unzip -q matomo.zip
# mv matomo /usr/share/nginx/html/
# chown -R nginx.nginx /usr/share/nginx/html
2、瀏覽器訪問http://192.168.0.122/matomo
除了“強制SSL連接”,其它都要通過檢查:
<!-- Matomo -->
<script type="text/javascript">
? var _paq = window._paq || [];
? /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
? _paq.push(['trackPageView']);
? _paq.push(['enableLinkTracking']);
? (function() {
??? var u="http://192.168.0.122/matomo/";
??? _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.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
? })();
</script>
<!-- End Matomo Code -->
沒有任何數據:
七、WordPress安裝配置Matomo插件:
1、安裝啟用插件:
2、配置插件:
上述認證令牌(Auth Token)的值來源于:Matomo網站 --> 右上角管理 --> 左側API
3、查看統計數據:
同時多開幾個瀏覽器訪問http://192.168.0.122/wordpress/,并刷新
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。