运行项目-博客
运行环境
主机 | 主机名 | 系统 | 服务 |
---|---|---|---|
192.168.48.130 | Server-Web | Linux | Web |
192.168.48.131 | Server-NFS-DNS | Linux | NFS/DNS |
基础配置
- 配置主机名,静态IP地址
- 开启防火墙并配置
- 部分开启SElinux并配置
- 服务器之间使用同ntp.aliyun.com进行时间同步
- 服务器之间实现SSH免密登录
操作
- 配置静态IP
定位192.168.48.130:
nmcli c modify ens160 ipv4.method manual\ipv4.addresses 192.168.48.130/24\ipv4.gateway 192.168.48.2\ipv4.dns 114.114.114.114
nmcli c reload
nmcli c up ens160
# 修改主机名及hosts映射
hostanmectl set-hostname server-web
vim /etc/hosts
127.0.0.1 Server-Web
192.168.48.130 Server-Web
192.168.48.131 Server-NFS-DNS
reboot
定位192.168.48.131:
nmcli c modify ens160 ipv4.method manual\ipv4.addresses 192.168.48.131/24\ipv4.gateway 192.168.48.2\ipv4.dns 114.114.114.114
nmcli c reload
nmcli c up ens160
- 修改主机名及hosts映射
定位192.168.48.130:
定位192.168.48.131:
hostanmectl set-hostname server-web
vim /etc/hosts
127.0.0.1 Server-NFS-DNS
192.168.48.130 Server-Web
192.168.48.131 Server-NFS-DNS
reboot
- 开启防火墙
定位双方机子:
systemctl start firewalld
systemctl enable firewalld
- 时间同步
定位双方机子:
vim /etc/chrony.conf
server ntp.aliyun.com iburst
systemctl restart chronyd
chrony sources -v
timedatectl status
- 配置免密ssh登录
定位192.168.48.130:
ssh-keygen -t rsa
ssh-copy-id 192.168.48.131
ssh 192.168.48.131
exit
定位192.168.48.131:
ssh-keygen -t rsa
ssh-copy-id 192.168.48.130
ssh 192.168.48.130
exit
- Server-web端(130)安装LNMP环境软件
yum install nginx mariadb-server php -y
- Server-NFS-DNS端上传博客软件
- 点击下载,下载后为zip压缩文件
- 将wordpress上传到192.168.48.131(Server-NFS-DNS)端的/目录下
- 解压缩
定位192.168.48.131:
cd /
unzip wordpress-6.1-zh_CN.zip
cd wordpress
ls#Server-NFS-DNSD端设置NFS共享
yum install rpcbind nfs-utils -y
vim /etc/exports
/wordpress 192.168.48.130(rw,sync,all_squash)#设置权限
chmod -Rf 777 /wordpress
firewall-cmd --permanent --zone public --add-service=mountd
firewall-cmd --permanent --zone public --add-service=rpc-bind
firewall-cmd --permanent --zone public --add-service=nfs
firewall-cmd --reload
systemctl start rpcbind
systemctl start nfs-server
定位192.168.48.130:
#挂载远程共享目录
yum install rpcbind -y
yum install nfs-utils -y
showmount -e 192.168.48.131
mkdir /wp
mount -t nfs 192.168.48.131:/wordpress /wp
cd /wp
ls#nginx设置
firewall-cmd --permanent --zone public --add-service=http
firewall-cmd --reload
vim /etc/nginx/nginx.confroot /wp;#在数据库中创建数据库和用户
mysql
create database wordpress;
create user 'test1'@'localhost' identified by '123456';
grant all on wordpress.* to 'test'@'localhost';
exit;#重启数据库和http
systemctl restart mariadb
systemctl restart nginx
- 配置wordpress
- 在windows端输入192.168.48.130继续完成wordpress配置(邮箱必须设置)
- 在Server-NFS-DNS端配置DNS
- 定位192.168.169.131:
- 原则:www.openlab.com 正向解析为192.168.48.130
yum install bind -y
firewall-cmd --permanent --zone public --add-service=dns
firewall-cmd --reload
systemctl start named#编辑主配置文件
vim /etc/named.conf
11 listen-on port 53 {any;};
19 allow-query {any;}#编辑区域配置文件
vim /etc/named.rfc1912.zones
zone "openlab.com" IN {type master;file master;file "openlab.com.zone";allow-update P none; };};
#新建区域数据文件并配置解析
cd /var/named
cp -a named.localhost openlab.com (0 ;serial1D ;refresh1H ;retry1W ;expire3H ) ;minimumNS ns.openlab.comns IN A 192.168.48.130www IN A 192.168.48.130 bbs IN A 192.168.48.130#启动服务
systemctl restart named
测试
将Server-Web端的DNS改为192.168.48.131后并输入www.openlab.com域名访问