现有主机 node01 和 node02,完成如下需求:
1、在 node01 主机上提供 DNS 和 WEB 服务
2、dns 服务提供本实验所有主机名解析
3、web服务提供 www.rhce.com 虚拟主机
4、该虚拟主机的documentroot目录在 /nfs/rhce 目录
5、该目录由 node02 主机提供的NFS服务共享
6、该目录可以通过autofs服务实现自动挂载
7、所有服务应该在重启之后依然可以正常使用
#关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
#下载http
[root@localhost ~]# yum install httpd -y
#编写配置文件
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
<directory /nfs>
allowoverride none
require all granted
</directory>
<virtualhost 10.10.10.5:80>
documentroot /nfs/rhce
servername www.rhce.com
</virtualhost>
[root@localhost ~]# mkdir /nfs
[root@localhost ~]# yum install rpcbind -y
[root@localhost ~]# yum install nfs-utils -y
[root@localhost ~]# yum install autofs -y
#先完成10.10.10.6配置完后配置
[root@localhost ~]# vim /etc/auto.master
#添加
nfs /etc/auto.nfs
[root@localhost ~]# vim /etc/auto.nfs
/rhce 10.10.10.6:/rhce
[root@localhost ~]# systemctl restart autofs
[root@localhost ~]# yum install bind -y
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { 10.10.10.5; };
directory "/var/named";
};
zone "rhce.com" IN {
type master;
file "named.rhce";
};
[root@localhost ~]# vim /var/named/named.rhce
$TTL 1d
@ IN SOA @ zhang.qq.com. (
0
1
1
1
1 )
IN NS ns.rhce.com.
ns IN A 10.10.10.5
www IN A 10.10.10.5
[root@localhost ~]# systemctl restart named
[root@localhost ~]# curl www.rhce.com
This is rhce
10.10.10.6
#关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
#创建目录
[root@localhost ~]# mkdir /rhce
[root@localhost ~]# echo "This is rhce" > /rhce/index.html
[root@localhost ~]# chmod 777 /rhce
#下载nfs
[root@localhost ~]# yum install rpcbind -y
[root@localhost ~]# yum install nfs-utils -y
#编写配置文件
[root@localhost ~]# vim /etc/exports
/rhce 10.10.10.5(rw)
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs-server
#查看挂载情况
[root@localhost ~]# showmount -e 10.10.10.6
Export list for 10.10.10.6:
/rhce 10.10.10.5
打开防火墙之后
10.10.10.5
#打开防火墙
[root@localhost ~]# systemctl start firewalld
[root@localhost ~]# setenforce 1
#添加放行规则
[root@localhost ~]# firewall-cmd --permanent --add-service=http
success
[root@localhost ~]# firewall-cmd --permanent --add-service=dns
success
[root@localhost ~]# firewall-cmd --permanent --add-service=nfs
success
[root@localhost ~]# firewall-cmd --permanent --add-service=mountd
success
[root@localhost ~]# firewall-cmd --permanent --add-service=rpc-bind
success
#重启防火墙
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# setsebool -P httpd_use_nfs 1
[root@localhost ~]# curl www.rhce.com
This is rhce