溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

發(fā)布時間:2020-02-29 05:48:15 來源:網(wǎng)絡(luò) 閱讀:727 作者:Marion0728 欄目:系統(tǒng)運維

WordPress是一款使用PHP語言開發(fā)的博客平臺,官網(wǎng)https://cn.wordpress.org/

Matomo的前身是Piwik,一套基于PHP + MySQL技術(shù)構(gòu)建的開源網(wǎng)站訪問統(tǒng)計系統(tǒng),Matomo可以提供統(tǒng)計網(wǎng)頁瀏覽人數(shù)、訪問最多的頁面、搜索引擎關(guān)鍵詞等流量分析功能,它還采用了插件擴展及開放API架構(gòu),可以讓用戶根據(jù)自已的實際需求創(chuàng)建更多的功能,軟件包下載和部署文檔地址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

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor


二、安裝配置MariaDB

CentOS 7.7默認(rèn)yum源中的MariaDB版本為5.5.64,此處安裝MariaDB 10.4版本

1、查看系統(tǒng)中是否已經(jīng)存在MariaDB,有則刪除:

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

# yum -y remove mariadb-libs

2、配置MariaDByum源:

# 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

備注:默認(rèn)主配置文件不是/etc/my.cnf,而是/etc/my.cnf.d/server.cnf

5、創(chuàng)建錯誤日志文件:

# 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安全配置向?qū)В?/span># mysql_secure_installation

8、授權(quán)用戶遠程登錄:

# mysql -uroot -p

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

MariaDB [(none)]> flush privileges;

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

9、創(chuàng)建wordpressmatomo數(shù)據(jù)庫:

MariaDB [(none)]> create database wordpress;

MariaDB [(none)]> create database matomo;

10、創(chuàng)建新用戶,并對其賦予數(shù)據(jù)庫權(quán)限:

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

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

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、創(chuàng)建測試頁:

# 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中使用舊版本PHPmysql_connect()函數(shù)連接MySQL,會提示“undefined function mysql_connect()”。從PHP 5.5版本開始,MySQL就不推薦使用mysql_connect()函數(shù),屬于廢棄函數(shù),PHP 7中已經(jīng)徹底不支持,增加了mysqli_connect()函數(shù)。從某種意義上說,mysqlimysql系統(tǒng)函數(shù)的增強版,更穩(wěn)定、更高效、更安全,屬于面向?qū)ο螅脤ο蟮姆绞讲僮黩?qū)動MySQL數(shù)據(jù)庫。

3、瀏覽器訪問http://192.168.0.122

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

停止MariaDB# systemctl stop mariadb.service

刷新頁面:

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor


五、安裝配置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

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

3、瀏覽器訪問http://192.168.0.122/wordpress

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor


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

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

除了“強制SSL連接”,其它都要通過檢查:

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

<!-- 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 -->

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

沒有任何數(shù)據(jù):

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor


七、WordPress安裝配置Matomo插件:

1、安裝啟用插件:

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

2、配置插件:

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

上述認(rèn)證令牌(Auth Token)的值來源于:Matomo網(wǎng)站 --> 右上角管理 --> 左側(cè)API

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

3、查看統(tǒng)計數(shù)據(jù):

同時多開幾個瀏覽器訪問http://192.168.0.122/wordpress/,并刷新

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

CentOS 7.7yum安裝方式搭建LNMP環(huán)境部署Wor

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI