192.168.32.132 Server-Web linux Web
192.168.32.133 Server-NFS-DNS linux NFS/DNS
基础配置
1.配置主机名+静态ip
2.开启防火墙并配置
3.部分开启selinux并配置
4.服务器之间通过阿里云进行时间同步
5.服务器之间实现ssh免密登录
业务需求
1.Server-web主机配置Web服务,通过域名www.opelab.com可以访问到自己建的博客网站
2.Server-NFS-DNS主机配置NFS服务,将博客网站资源共享给Server-web主机,同时配置DNS服务
[root@Server ~]#hostnamectl set-hostname Server-web
[root@node ~ ]#hostnamectl set-hostname Server-NFS-DNS
在两个主机中进行host映射
#vim /etc/hosts
#reboot
[root@Server-NFS-DNS ~]# nmcli c mod ens32 ipv4.method manual ipv4.address 192.168.32.133/24 ipv4.gateway 192.168.32.2 ipv4.dns 114.114.114.114
[root@Server-NFS-DNS ~]# nmcli c reload
[root@Server-NFS-DNS ~]# nmcli c up ens32
[root@Server-web ~]# nmcli c mod ens32 ipv4.method manual ipv4.address 192.168.32.132/24 ipv4.gateway 192.168.32.2 ipv4.dns 192.168.32.133
[root@Server-web ~]# nmcli c reload
[root@Server-web ~]# nmcli c up ens32
#查看DNS:[root@Server-NFS-DNS ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32
#开启防火墙,两个主机都操作
systemctl start firewalld
systemctl enable firewalld
#开启selinux,Server-web端关闭,Server-NFS-DNS端开启
关闭:setenforce 0
开启:setenforce 1
#若是开启失败,则:
[root@Server-NFS-DNS ~]#yum install selinux-policy selinux-policy-targeted -y
[root@Server-NFS-DNS ~]#vim /etc/seliux/config
SELINUX=permissive
[root@Server-NFS-DNS ~]#touch /.autorelabel
[root@Server-NFS-DNS ~]#reboot
#两台主机都操作
#yum install chrony -y
#vim /etc/chrony.conf
server ntp.aliyun.com iburst
#systemctl restart chronyd
#chronyc sources -v
#timedatectl status
[root@Server-NFS-DNS ~]# ssh-keygen -t rsa
[root@Server-NFS-DNS ~]# ssh-copy-id 192.168.32.132
[root@Server-web ~]# ssh-keygen -t rsa
[root@Server-web ~]# ssh-copy-id 192.168.32.133
[root@Server-web ~]#yum install nginx mariadb-server php* -y
博客压缩包下载链接: Release Archive | WordPress.org China 简体中文
[root@Server-NFS-DNS ~]# cd /
[root@Server-NFS-DNS ~]# unzip wordpress-6.1-zh_CN.zip
[root@Server-NFS-DNS ~]# yum install rpcbind -y
[root@Server-NFS-DNS ~]# yum install nfs-utils -y
[root@Server-NFS-DNS ~]# vim /etc/exports
/wordpress 192.168.32.132(rw,sync,all_squash)
#设置权限
[root@Server-NFS-DNS ~]# chmod -Rf 777 /wordpress
#防火墙放行及启动
[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=mountd
[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=rpc-bind
[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=nfs
[root@Server-NFS-DNS ~]# firewall-cmd --reload
[root@Server-NFS-DNS ~]# systemctl start rpcbind
[root@Server-NFS-DNS ~]# systemctl start nfs-utils
#设置zseliux的上下文文件
[root@Server-NFS-DNS ~]# ls -Z /usr/share/nginx/html
[root@Server-NFS-DNS ~]# chcon -t httpd_sys_content_t /wordpress -Rv
R代表递归修改目录,v表示显示修改提示
#临时挂载
[root@Server-web ~]# yum install nfs-utils -y
[root@Server-web ~]# showmount -e 192.168.32.133
[root@Server-web ~]# mkdir -pv /wp
[root@Server-web ~]# mount -t nfs 192.168.32.133:/wordpress /wp
[root@Server-web ~]# cd /wp
[root@Server-web ~]# ll
若是想开机自动挂载,可以先查看分区的uuid,
#blkid
编辑开机自动挂载文件:
#vim /etc/fstab
UUID=6b1c1143-4556-46b9-9d44-0a60c993825e / xfs defaults 0 0
[root@Server-web ~]# firewall-cmd --permanent --zone public --add-service=http
[root@Server-web ~]# firewall-cmd --permanent --zone public --add-port=80/tcp
[root@Server-web ~]# firewall-cmd --reload
[root@Server-web ~]# vim /etc/ngx/nginx.conf
[root@Server-web ~]#systemctl restart nginx
启动数据库:systemctl start mariadb
[root@Server-web ~]#mysql
>create database wordpress;
>create user 'test1'@'localhost' identified by '1234';
>grant all on wordpress.* to 'test1'@'localhost'; #授权
>exit
修改wordpress 配置文件
[root@Server-web ~]#cd /wp
[root@Server-web wp]#cp wp-config-sample.php wp-config.php
[root@Server-web wp]#vim wp-config.php
systemctl restart mariadb
systemctl restart nginx
[root@Server-NFS-DNS ~]# yum install bind -y
[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone pulic --add-servce=dns
[root@Server-NFS-DNS ~]# firewall-cmd --reload
[root@Server-NFS-DNS ~]# systemctl start named
[root@Server-NFS-DNS ~]# vim /etc/named.conf
[root@Server-NFS-DNS ~]# vim /etc/named.rfc1912.zones
[root@Server-NFS-DNS ~]# cd /var/named
[root@Server-NFS-DNS ~]# cp -a named.localhost openlab.com
[root@Server-NFS-DNS named]# vim openlab.com
[root@Server-NFS-DNS ~]# systemctl restart named