//下面是配置DNS服务器,添加两个区域,如果前面或者上课做过了的可以不用做 vi /etc/named.conf 两个any
vi /etc/named.rfc1912.zones //改主配置文件,添加day18.net和night18.net
zone "day18.net." IN { type master; file "day18.net.zone"; allow-update { none; }; };
zone "night18.net." IN { type master; file "night18.net.zone"; allow-update { none; }; };
cd /var/named cp -p named.localhost day18.net.zone vi day18.net.zone @ NS dns.day18.net. dns A 172.16.118.118 www A 172.16.118.118 cp -p day18.net.zone night18.net.zone vi night18.net.zone @ NS dns.night18.net. dns A 172.16.118.118 www A 172.16.118.118
//下面是使用apache来建立2个基于域名的虚拟主机站点 和建立主页 cd /var/www/html/ mkdir day18 vi day18/index.html this is day18.net's web page //写入的内容 mkdir night18 vi night18/index.html this is night18.net's web page //写入的内容 cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak //备份httpd.conf vi /etc/httpd/conf/httpd.conf #ServerName www.example.com:80//把#去掉,www.example.com改为自己的IP地址,如下 #ServerName 172.16.118.118:80 //再添加如下内容 <VirtualHost 172.16.118.118> DocumentRoot /var/www/html/day18 ServerName www.day18.net </VirtualHost> <VirtualHost 172.16.118.118> DocumentRoot /var/www/html/night18 ServerName www.night18.net </VirtualHost>
systemctl restart httpd //重启HTTPD服务,这里要等待一回
//测试 在win7中输入www.day18.net和www.night18.net测试 在Linux中测试输入 curl 172.16.118.118 [root@lai18 html]# curl 172.16.118.118 this is day18.net's web page