現有主機 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. (01111 )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