CentOS 7.7 environment to build LNMP deploy WordPress, and monitoring the use of Matomo

WordPress is a use of PHP language development blog platform, the official website https://cn.wordpress.org/

Matomo , formerly known as Piwik , based on a set of PHP + MySQL open source website statistics system technology to build, Matomo can provide statistical number of visitors, most visited pages, search engine keywords such as traffic analysis, it also uses plug-ins and extensions open API architecture that allows users to create more functionality according to their own actual demand, package download and deployment documentation addresses https://matomo.org/docs/installation/

First, the installation configuration Nginx :

1, installation epel Source: # RPM -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-7.noarch.rpm

2, mounting the Nginx : # yum the install Nginx -Y

3, start Nginx :

# systemctl start nginx

# systemctl status nginx

# ss -tunlp | grep -w :80

# systemctl enable nginx

4, browser access: http://192.168.0.122

image.png


Second, the installation configuration MariaDB :

CentOS 7.7 default yum source MariaDB version 5.5.64 , installed here MariaDB 10.4 versions

1, to see whether the system already exists MariaDB , there is deleted:

# rpm -qa | grep -i mariadb --> mariadb-libs-5.5.64-1.el7.x86_64

# yum -y remove mariadb-libs

2, the configuration MariaDB the yum source:

# 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, modify the configuration file 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

data = / 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

Note: The default main configuration file is not /etc/my.cnf , but /etc/my.cnf.d/server.cnf

5, creates the error log file:

# touch /var/log/mariadb.log

# chown mysql.mysql /var/log/mariadb.log

6, start 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 Security Configuration Wizard: # mysql_secure_installation

8, authorized users to remotely log in:

# mysql -uroot -p

MariaDB [(none)]> grant all on *.* to 'root'@'192.168.0.%' identified by '123456';

MariaDB [(none)]> flush privileges;

image.png

9, create wordpress and matomo database:

MariaDB [(none)]> create database wordpress;

MariaDB [(none)]> create database matomo;

10, create a new user, and gives their database privileges:

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;


Third, the installation configuration PHP :

1, install 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

image.png

2, modify www.conf configuration file:

# vim /etc/php-fpm.d/www.conf

user = apache --> user = nginx

group = apache --> group = nginx

3, start the PHP-FPM :

# systemctl start php-fpm.service

# systemctl status php-fpm.service

# Ss -tunlp | grep 9000

# systemctl enable php-fpm.service


Four, Nginx integration of PHP :

1, modify nginx.conf configuration file:

# 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. Create a test page:

# 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();

?>

Note: If the new version of PHP to use the old version of PHP 's mysql_connect () function to connect MySQL , you are prompted to " undefined function mysql_connect () ." From PHP 5.5 start version, MySQL is not recommended to use mysql_connect () function, which belongs to the waste function, PHP 7 has been completely do not support an increase of mysqli_connect () function. In a sense, mysqli is mysql enhanced version of the system functions, more stable, more efficient, safer, are object-oriented, object manipulation mode driver MySQL database.

3, browser access http://192.168.0.122

image.png

停止MariaDB# systemctl stop mariadb.service

refresh page:

image.png


Fifth, the installation configuration 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

image.png

3、浏览器访问http://192.168.0.122/wordpress

image.png

image.png

image.png

image.png

image.png


六、安装配置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

image.png

image.png

除了“强制SSL连接”,其它都要通过检查:

image.png

image.png

image.png

image.png

image.png

image.png

<!-- 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="//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 -->

image.png

image.png

没有任何数据:

image.png


七、WordPress安装配置Matomo插件:

1、安装启用插件:

image.png

image.png

2、配置插件:

image.png

image.png

The authentication token ( the Auth the Token value) derived from: Matomo Website -> top right Management -> left API

image.png

image.png

image.png

image.png

3, view statistics:

At the same time to open several browser to access http://192.168.0.122/wordpress/ , and refresh

image.png

image.png

image.png

image.png


Guess you like

Origin blog.51cto.com/qiuyue/2448400