首先我们给服务器改一个名字 hostname NFS bash hostname WEB bash
NFS的IP为:172.24.8.128 WEB的IP为:172.24.8.129
然后我们在NFS上的配置: mount /dev/sr0 /mnt vim /etc/yum.repos.d/base.repo 进入vim里面编辑: [BaseOS] name = BaseOS baseurl = file:///mnt/BaseOS gpgcheck = 0 [AppStream] name = Appstrea baseurl = file:///mnt/AppStream gpgcheck = 0 wq 完成yum的环境配置 yum install nfs-utils -y yum install rpcbind -y systemctl start nfs-server systemctl stop firewalld setenforce 0
vim /etc/exports /openlab *(rw) /xianoupeng *(rw)
mkdir /xianoupeng mkdir /openlab exportfs -ar echo this xianoupeng > /xianoupeng/index.html写网页内容 echo this openlab > /openlab/index.html
然后在WEB上配置:
systemctl stop firewalld setenforce 0 mount /dev/sr0 /mnt yum install httpd -y systemctl start httpd mkdir /openlab mkdir /xianoupeng mount 172.24.8.128:/openlab /openlab mount 172.24.8.128:/xianoupeng /xianoupeng
vim /etc/httpd/conf.d/vhos <VirtualHost 172.24.8.129:80> Servername www.xianoupeng.com Documentroot /xianoupeng <Directory /xianoupeng> AllowOverride none Require all granted <VirtualHost 172.24.8.129:80> Servername www.openlab.com Documentroot /openlab <Directory /openlab> AllowOverride none Require all granted wq
systemctl restart httpd
vim /etc/hosts 172.24.8.129 www.xianoupeng.com 172.16.8.129 www.openlab.com wq
最后在web上验证 ping www.xianoupeng.com ping www.openlab.com curl www.xianoupeng.com curl www.openlab.com
访问web上的是: this xianoupeng this openlab 即实验成功如果为乱码就要检查html
|