分布式搭载博客网站

一.运行环境:

|-----------------|----------------|-------|---------|
| IP | 主机名 | 系统 | 服务 |
| 192.168.118.128 | Server-Web | Linux | Web |
| 192.168.118.131 | Server-NFS-DNS | Linux | NFS/DNS |

二.基础配置

  1. 配置主机名,hosts映射

[root@server ~]# hostnamectl set-hostname Server-Web
[root@server ~]# hostname
Server-Web
[root@server ~]#vim /etc/hosts
127.0.0.1 Server-Web
192.168.118.128 Server-Web
192.168.118.131 Server-NFS-DNS
[root@server ~]# reboot

[root@node ~]# hostnamectl set-hostname Server-NFS-DNS
[root@node ~]# hostname
Server-NFS-DNS
[root@node ~]# reboot
[root@Server-NFS-DNS ~]# vim /etc/hosts
127.0.0.1 Server-NFS-DNS
192.168.118.128 Server-Web
192.168.118.131 Server-NFS-DNS

  1. 开启防火墙并配置

相同操作:
[root@Server-NFS-DNS ~]# systemctl start firewalld
[root@Server-NFS-DNS ~]# systemctl enable firewalld

  1. 服务器之间使用同 ntp.aliyun.com 进行时间同步

相同操作:
vim /etc/chrony.conf
server ntp.aliyun.com iburst
systemctl restart chronyd
chronyc sources -v
timedatectl status

  1. 服务器之间实现 SSH 免密登录
    Server-Web:

[root@Server-Web ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:kNDhoYpfc4CEb5NVN+WC39+sPbE2FausptyEzk5qs0s root@Server-Web
The key's randomart image is:
+---[RSA 3072]----+
| .. .o+.o.. |
|.. ..+.= o |
| ..oo = . . |
| .=. . o o . |
|....o . S . o|
| . . o .. o...|
| . E o .o ++ |
| .o* o. == |
| .+=*ooo..o |
+----[SHA256]-----+
[root@Server-Web ~]# ssh-copy-id 192.168.118.131
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.118.131 (192.168.118.131)' can't be established.
ED25519 key fingerprint is SHA256:OXWoro2/b049fk8uPMIfR4b5nj0v8M3PoMq+75B1jaM.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Authorized users only. All activities may be monitored and reported.
root@192.168.118.131's password:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh '192.168.118.131'"
and check to make sure that only the key(s) you wanted were added.

[root@Server-Web ~]# ssh 192.168.118.131

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Last login: Wed Apr 17 11:39:31 2024 from 192.168.118.1

Welcome to 5.10.0-182.0.0.95.oe2203sp3.x86_64

System information as of time: 2024年 04月 17日 星期三 11:44:11 CST

System load: 0.00
Processes: 193
Memory used: 10.4%
Swap used: 0%
Usage On: 12%
IP address: 192.168.118.131
Users online: 2

[root@Server-NFS-DNS ~]# exit
注销
Connection to 192.168.118.131 closed.
[root@Server-Web ~]#

Server-NFS-DNS:

[root@Server-NFS-DNS ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:gwX4W59iAtyPksBTA6D0gKYuPvi2LDgkTbeysPG1pzU root@Server-NFS-DNS
The key's randomart image is:
+---[RSA 3072]----+
|o+.. .. |
|+.o + . |
|+. + + . |
|. = + oo. |
|.o + +.=S. . |
|=oo = + +.o |
|B= + oEo . |
|*++ .... |
| ==..o |
+----[SHA256]-----+
[root@Server-NFS-DNS ~]# ssh-copy-id 192.168.118.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Authorized users only. All activities may be monitored and reported.
root@192.168.118.128's password:

Number of key(s) added: 1

Now try logging into the machine, with: "ssh '192.168.118.128'"
and check to make sure that only the key(s) you wanted were added.

[root@Server-NFS-DNS ~]# ssh 192.168.118.128

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Last login: Wed Apr 17 11:39:22 2024 from 192.168.118.1

Welcome to 5.10.0-182.0.0.95.oe2203sp3.x86_64

System information as of time: 2024年 04月 17日 星期三 11:48:15 CST

System load: 0.00
Processes: 195
Memory used: 10.2%
Swap used: 0%
Usage On: 12%
IP address: 192.168.118.128
Users online: 2

[root@Server-Web ~]# exit
注销
Connection to 192.168.118.128 closed.
[root@Server-NFS-DNS ~]#

三.环境搭建:

Server-Web: yum install nginx mariadb-server php* -y

Server-NFS-DNS: 将wordpress上传到Server-NFS-DNS)端的/目录下

[root@Server-NFS-DNS ~]# cd /

[root@Server-NFS-DNS /]# ls

afs dev lib media proc sbin tmp wordpress-6.1-zh_CN.zip

bin etc lib64 mnt root srv usr

boot home lost+found opt run sys var

[root@Server-NFS-DNS /]# unzip wordpress-6.1-zh_CN.zip

[root@Server-NFS-DNS /]# ls
afs dev lib media proc sbin tmp wordpress
bin etc lib64 mnt root srv usr wordpress-6.1-zh_CN.zip
boot home lost+found opt run sys var
[root@Server-NFS-DNS /]# cd wordpress
[root@Server-NFS-DNS wordpress]# ls
index.php wp-config-sample.php wp-mail.php
license.txt wp-content wp-settings.php
readme.html wp-cron.php wp-signup.php
wp-activate.php wp-includes wp-trackback.php
wp-admin wp-links-opml.php xmlrpc.php
wp-blog-header.php wp-load.php
wp-comments-post.php wp-login.php

四.将Server-NFS-DNS端的/wordpress 目录共享给 Server-Web

[root@Server-NFS-DNS wordpress]# yum install rpcbind nfs-utils -y

[root@Server-NFS-DNS wordpress]# cd ~

[root@Server-NFS-DNS ~]# vim /etc/exports

[root@Server-NFS-DNS ~]# chmod -Rf 777 /wordpress

/wordpress 192.168.118.128(rw,sync,all_squash)

防火墙开启权限:

[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=mountd

success

[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=rpc-bind

success

[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=nfs

success

[root@Server-NFS-DNS ~]# firewall-cmd --reload

success

启动服务:

[root@Server-NFS-DNS ~]# systemctl start rpcbind

[root@Server-NFS-DNS ~]# systemctl start nfs-server

五.Server-web设置:

[root@Server-Web ~]#yum install rpcbind nfs-utils -y

[root@Server-Web ~]# showmount -e 192.168.118.131

Export list for 192.168.118.131:

192.168.118.128(rw,sync,all_squash) *

/wordpress *

[root@Server-Web ~]# mkdir /wp

[root@Server-Web ~]# mount -t nfs 192.168.118.131:/wordpress /wp

[root@Server-Web ~]# ls

anaconda-ks.cfg

[root@Server-Web ~]# cd /wp

[root@Server-Web wp]# ls

index.php wp-config-sample.php wp-mail.php

license.txt wp-content wp-settings.php

readme.html wp-cron.php wp-signup.php

wp-activate.php wp-includes wp-trackback.php

wp-admin wp-links-opml.php xmlrpc.php

wp-blog-header.php wp-load.php

wp-comments-post.php wp-login.php

六.Nginx设置:

[root@Server-Web ~]# firewall-cmd --permanent --zone public --add-service=http

success

[root@Server-Web ~]# firewall-cmd --reload

success

[root@Server-Web ~]# vim /etc/nginx/nginx.conf

七.修改wordpress配置文件

[root@Server-Web /]# cd wp

[root@Server-Web wp]# ls

index.php wp-config-sample.php wp-mail.php

license.txt wp-content wp-settings.php

readme.html wp-cron.php wp-signup.php

wp-activate.php wp-includes wp-trackback.php

wp-admin wp-links-opml.php xmlrpc.php

wp-blog-header.php wp-load.php

wp-comments-post.php wp-login.php

[root@Server-Web wp]# cp wp-config-sample.php wp-config.php

[root@Server-Web wp]# vim wp-config.php

define( 'DB_NAME', 'wordpress' );

/** Database username */

define( 'DB_USER', 'LYY' );

/** Database password */

define( 'DB_PASSWORD', '123456' );

八.数据库设置

[root@Server-Web ~]# systemctl start mariadb

[root@Server-Web ~]# mysql

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 10.5.22-MariaDB 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.001 sec)

MariaDB [(none)]> create user 'LYY'@'localhost' identified by '123456';

Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all on wordpress.* to 'LYY'@'localhost';

Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> exit

Bye

[root@Server-Web ~]# systemctl restart mariadb

[root@Server-Web ~]# systemctl restart nginx

九.windows设置

十. Server-NFS-DNS端配置DNS

[root@Server-NFS-DNS ~]# cd ~

[root@Server-NFS-DNS ~]# yum install bind -y

[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=dns

success

[root@Server-NFS-DNS ~]# firewall-cmd --reload

success

[root@Server-NFS-DNS ~]# systemctl start named

[root@Server-NFS-DNS ~]# vim /etc/named.conf

[root@Server-NFS-DNS ~]# vim /etc/named.rfc1912.zones

zone "openlab.com" IN {

type master;

file "openlab.com.zone";

allow-update { none; };

};

[root@Server-NFS-DNS ~]# cd /var/named/

[root@Server-NFS-DNS named]# cp -a named.localhost openlab.com.zone

[root@Server-NFS-DNS named]# vim openlab.com.zone

$TTL 1D

@ IN SOA openlab.com. admin.openlab.com. (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

NS ns.openlab.com.

ns IN A 192.168.118.128

www IN A 192.168.118.128

bbs IN A 192.168.118.128

[root@Server-NFS-DNS named]# systemctl restart named
Server-Web 端的 DNS 改为 192.168.118.131

十一.完成,输入域名访问

相关推荐
热爱嵌入式的小许2 小时前
Linux基础项目开发1:量产工具——显示系统
linux·运维·服务器·韦东山量产工具
小堃学编程2 小时前
计算机网络(十) —— IP协议详解,理解运营商和全球网络
网络·tcp/ip·计算机网络
IPFoxy6665 小时前
探索路由器静态IP的获取方式
网络·智能路由器
menge23335 小时前
VLAN:虚拟局域网
网络·智能路由器
ZachOn1y6 小时前
计算机网络:计算机网络概述 —— 初识计算机网络
网络·计算机网络·知识点汇总·考研必备
三金121386 小时前
SpringIoC容器的初识
网络·网络协议·rpc
韩楚风6 小时前
【linux 多进程并发】linux进程状态与生命周期各阶段转换,进程状态查看分析,助力高性能优化
linux·服务器·性能优化·架构·gnu
陈苏同学6 小时前
4. 将pycharm本地项目同步到(Linux)服务器上——深度学习·科研实践·从0到1
linux·服务器·ide·人工智能·python·深度学习·pycharm
Ambition_LAO6 小时前
解决:进入 WSL(Windows Subsystem for Linux)以及将 PyCharm 2024 连接到 WSL
linux·pycharm
Pythonliu76 小时前
茴香豆 + Qwen-7B-Chat-Int8
linux·运维·服务器