ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

CentOS 8部署分布式LNMP+WordPress

2022-01-09 20:02:56  阅读:250  来源: 互联网

标签:www CentOS LNMP 192.168 nginx WordPress root 节点 fastcgi


一、实验环境

1、节点规则

IP地址主机名称 节点说明
192.168.18.8masterdb数据库主节点
192.168.18.18nginxnginx服务器节点
192.168.18.88slavedb数据库从节点
192.168.18.188phpPHP环境节点

2、节点服务安装

(1)部署和配置分布式主从数据库服务器,详见:

CentOS8部署MariaDB分布式主从数据库服务_u013007181的博客-CSDN博客目录一、安装环境二、初始化数据库三、配置主节点masterdb四、配置从节点slavedb五、验证数据库主从服务一、安装环境准备1、节点规划准备两台虚拟主机,分别扮演主数据库节点(masterdb)和从数据库节点(slavedb)IP地址主机名称节点192.168.18.8masterdb主数据库节点192.168.18.100slavedb从数据库节点2、主数据库节点设置[root@red3212.https://blog.csdn.net/u013007181/article/details/122349925(2)部署和配置php环境节点,详见:

Centos8 下安装和配置 PHP 8.1.1环境_u013007181的博客-CSDN博客一、安装环境:[root@red3212 ~]# cat /etc/redhat-release CentOS Linux release 8.3.2011[root@red3212 ~]# ifconfig ens32ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.18.89 netmask 255.255.255.0 broadcast 192.168.18.25https://blog.csdn.net/u013007181/article/details/122339130(3)部署和配置nginx服务器节点,详见:

CentOS8 下部署Nginx服务_u013007181的博客-CSDN博客一、安装环境:[root@red3212 ~]# cat /etc/redhat-release CentOS Linux release 8.3.2011[root@red3212 ~]# ifconfig ens32ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.18.89 netmask 255.255.255.0 broadcast 192.168.18.25https://blog.csdn.net/u013007181/article/details/122348523二、配置Nginx服务

(1)编辑修改nginx配置文件

[root@red3212 ~]# vim /usr/local/nginx/conf/nginx.conf
……此处省略部分信息……
        location / {
            root   /www;
            index  index.php  index.html index.htm;
        }
……此处省略部分信息……
#将以下7行前面注释符#号删除,并更改注释中的内容
        location ~ \.php$ {
            root           /www;
            fastcgi_pass   192.168.18.188:9000; #此处的IP地址是PHP服务节点的IP
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;  #将/scripts更改为$document_root
            include        fastcgi_params;
        }

(2)编辑修改fastcgi_params配置文件

[root@red3212 ~]# vim /usr/local/nginx/conf/fastcgi_params
……

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  FILESCRIPT_NAME    $document_root$fastcgi_script_name;  #添加此行内容
fastcgi_param  REQUEST_URI        $request_uri;

……

三、创建网站根目录

(1)在nginx节点上自定义网站根目录,并更改属主为nginx

[root@nginxnode ~]# mkdir /www
[root@nginxnode ~]# chown -Rf nginx:nginx /www/

(2)在PHP服务节点上自定义网站根目录,并更改属主为nginx

[root@phpnode ~]# mkdir /www
[root@phpnode ~]# chown -Rf nginx:nginx /www/

四、部署Wordpress

(1)在Nginx节点中下载并解压wordpress到/www目录

[root@nginxnode ~]# wget https://cn.wordpress.org/latest-zh_CN.tar.gz
[root@nginxnode ~]# tar -xzvf latest-zh_CN.tar.gz 
[root@nginxnode ~]# mv wordpress/* /www

(2)PHP节点中下载并解压wordpress到/www目录

[root@phpnode ~]# wget https://cn.wordpress.org/latest-zh_CN.tar.gz -P /www
[root@phpnode ~]# tar -xzvf latest-zh_CN.tar.gz 
[root@phpnode ~]# mv wordpress/* /www

(3)在Nginx节点中修改Wordpress的配置文件

[root@nginxnode ~]# cd /www
[root@nginxnode www]# cp wp-config-sample.php wp-config.php
[root@nginxnode www]# vim wp-config.php 
……此处省略部分信息……
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'zhangsan' );

/** MySQL database password */
define( 'DB_PASSWORD', 'Mima1234' );

/** MySQL hostname */
define( 'DB_HOST', '192.168.18.8' );    #此处的IP地址为主数据库IP地址

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
……此处省略部分信息……

(4)将nginx节点中的wp-config.php配置文件复制到PHP节点的/www目录下

[root@nginxnode www]# scp /www/wp-config.php 192.168.18.188:/www

五、在主数据库节点中创建数据库和用户

[root@masterdb ~]# mysql -u root -p666666
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.3.28-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.014 sec)

MariaDB [(none)]> create user 'zhangsan'@'%' identified by 'Mima1234';
Query OK, 0 rows affected (0.020 sec)

MariaDB [(none)]> grant all privileges on wordpress.* to 'zhangsan'@'%';
Query OK, 0 rows affected (0.022 sec)

六、测试访问Wordpress

在浏览器中输入nginx服务器的IP地址进行访问,就会出现如下图所示的Wordpress的安装界面。

 

标签:www,CentOS,LNMP,192.168,nginx,WordPress,root,节点,fastcgi
来源: https://blog.csdn.net/u013007181/article/details/122374413

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有