题目如下:
配置nfs服务器和web服务器
1.配置nfs服务器,要求将两个网站的资源文件通过nfs服务器共享给web服务器。
通过两个共享目录分别网页文件例如:/openlab/index.html
/xianoupeng/index.html (网页文件内容自定义)。
2.通过nfs共享网页文件,配置web服务实现www.openlab.com以及www.xianoupeng.com访问各自的网站信息。
分两个步骤,一个是在NFS服务器上,另一个在WEB服务器上,用到两台linux虚拟机
NFS上:
1.确认服务是否已经安装
[root@NFS ~]# rpm -q rpcbind
[root@NFS ~]# rpm -q nfs-utils
如果没有安装,先挂载,再执行yum install rpcbind -y和yum install nfs-utils -y
2.启动服务
[root@NFS ~]# systemctl start nfs-server
[root@NFS ~]# systemctl stop firewalld
[root@NFS ~]# setenforce 0
3.创建目录
[root@NFS ~]# mkdir /openlab
[root@NFS ~]# mkdir /xianoupeng
[root@NFS ~]# echo this is openlab > /openlab/index.html
[root@NFS ~]# echo this is xianoupeng > /xianoupeng/index.html
4.写共享目录的路径
[root@NFS ~]# vim /etc/exports
*代表所有客户端都有读写权限,可以写具体的主机ip
6.
[root@NFS ~]# exportfs -ar或者systemctl restart nfs-server
在WEB服务器上:
先安装httpd服务,详情请看我前两条blog
1.创建两个挂在目录,然后挂载
[root@WEB ~]# mkdir /copenlab
[root@WEB ~]# mkdir /cxianoupeng
[root@WEB ~]# mount 192.168.28.129:/xianoupeng /cxianoupeng
[root@WEB ~]# mount 192.168.28.129:/openlab /copenlab
2.配置文件
[root@WEB ~]# vim /etc/httpd/conf.d/vhost.conf
3.在hosts下添加
[root@WEB ~]# vim /etc/hosts
测试结果: