Get the App
SLTechnology News&Howtos  ›  Servers  › 

CentOS 7.7yum installation way to set up LNMP environment and deploy Wor

Shulou Source: shulou.com Published: 2022-06-03 09:42:34 10月23日 Update

WordPress is a blog platform developed using PHP language, official website cn.wordpress.org/

Matomo's predecessor is Piwik, an open source website visit statistics system based on PHP + MySQL technology. Matomo can provide statistics on the number of web visitors, the most visited pages, search engine keywords and other traffic analysis functions. It also adopts plug-in extensions and open API architecture, allowing users to create more functions according to their actual needs. Software package download and deployment Document address matomo.org/docs/installation/

First, install configuration Nginx:

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

# yum -y install nginx

3. Start Nginx:

# systemctl start nginx

# systemctl status nginx

# ss -tunlp | grep -w :80

# systemctl enable nginx

4. Browser visit: 192.168.0.122

II. Installation and configuration MariaDB:

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

1. Check whether MariaDB already exists in the system, and delete it if yes:

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

# yum -y remove mariadb-libs

2. Configure the yum source of MariaDB:

# 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

Install 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

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

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

5. Create an error log file:

# touch /var/log/mariadb.log

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

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

MariaDB Security Configuration Wizard: # mysql_secure_installation

8. Authorized user remote login:

# mysql -uroot -p

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

MariaDB [(none)]> flush privileges;

Create WordPress and Matomo databases:

MariaDB [(none)]> create database wordpress;

MariaDB [(none)]> create database matomo;

10. Create a new user and grant it database permissions:

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;

3. Installation Configuration PHP:

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

2. Modify the www.conf configuration file:

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

user = apache --> user = nginx

group = apache --> group = nginx

3. Start php-fpm:

# systemctl start php-fpm.service

# systemctl status php-fpm.service

# ss -tunlp | grep 9000

# systemctl enable php-fpm.service

Nginx Integration PHP:

1. Modify the 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

Note: If you connect to MySQL using the mysql_connect() function of the old PHP in a new version of PHP, you will be prompted with "undefined function mysql_connect()". Since PHP 5.5, MySQL does not recommend the use of mysql_connect() function, which is an obsolete function. PHP 7 has completely no support for mysql_connect() function. In a sense, mysqli is an enhanced version of mysql system functions, more stable, more efficient, and more secure. It is object-oriented and uses object-driven operations to drive MySQL databases.

3. Visit http://www.example.com with browser 192.168.0.122

Stop MariaDB: # systemctl stop mariadb.service

Refresh page:

V. Installation Configuration WordPress:

1, Decompress WordPress: # tar -xf wordpress-5.2.4-zh_CN.tar.gz -C /usr/share/nginx/html/

2. Modify the wp-config.php configuration file:

# cd /usr/share/nginx/html/wordpress

# cp wp-config-sample.php wp-config.php

# vim wp-config.php

3. Visit http://www.example.com with browser 192.168.0.122/wordpress

VI. Installation configuration Matomo:

1. Decompress Matomo:

# yum -y install unzip

# unzip -q matomo.zip

# mv matomo /usr/share/nginx/html/

# chown -R nginx.nginx /usr/share/nginx/html

2. Visit http://www.example.com with browser 192.168.0.122/matomo

Except for "forced SSL connection," everything else must pass the check:

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[xss_clean].insertBefore(g,s);

})();

No data available:

VII. WordPress installation configuration Matomo plugin:

1. Install and enable plug-ins:

2. Configure plug-ins:

The value of the above Auth Token comes from Matomo website--> upper right corner management--> left API

3. View statistics:

Open several browsers at the same time, visit http://192.168.0.122/wordpress/, and refresh

Tags: Configuration files browsing functions data browsers plug-ins versions databases users systems statistics security features comments objects websites pages people tokens Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Docker NVidia MySQL Xiaomi