您好,登錄后才能下訂單哦!
[root@centos01 ~]# yum -y install bind bind-chroot bind-utils <!--安裝DNS依賴程序-->
[root@centos01 ~]# cp /etc/named.conf /etc/named.conf.bak <!--備份主配置文件-->
[root@centos01 ~]# echo "" > /etc/named.conf <!--清空主配置文件內(nèi)容->
[root@centos01 ~]# vim /etc/named.conf <!--編輯主配置文件-->
options{ <!--全局配置文件-->
listen-on port 53 { any; }; <!--53號(hào)端口監(jiān)聽(tīng)所有IP地址-->
directory "/var/named"; <!--區(qū)域配置文件位置-->
};
zone "benet.com" IN { <!--正向解析區(qū)域名稱-->
type master; <!--主DNS服務(wù)器-->
file "benet.com.zone"; <!--正向解析區(qū)域配置文件名字-->
allow-transfer { 192.168.100.20; }; <!--備用DNSIP地址-->
};
zone "accp.com" IN {
type master;
file "accp.com.zone";
allow-transfer { 192.168.100.20; };
};
[root@centos01 ~]# named-checkconf -z /etc/named.conf <!--檢查主配置文件是否錯(cuò)誤-->
[root@centos01 ~]# vim /var/named/benet.com.zone <!--編制benet的正向解析配置文件-->
$TTL 86400 <!--解析資源記錄有效時(shí)間24小時(shí)-->
@ SOA benet.com. root.benet.com( <!--域名為benet.com-->
2020020910 <!--更新序列號(hào)-->
1H <!--刷新時(shí)間1小時(shí)-->
15M <!--重試時(shí)間15分鐘-->
1W <!--失效時(shí)間1周-->
1D <!--無(wú)效解析記錄保存時(shí)間1天-->
)
@ NS centos01.benet.com. <!--主權(quán)威服務(wù)器是DNS完全合格域名-->
NS centos02.benet.com. <!--備-->
centos01 A 192.168.100.10 <!--記錄正向解析條目-->
centos02 A 192.168.100.20 <!--記錄正向解析條目-->
ftp A 192.168.100.10 <!--ftp服務(wù)器IP地址-->
www A 192.168.100.10 <!--網(wǎng)站服務(wù)器IP地址-->
[root@centos01 ~]# named-checkzone benet.com /var/named/benet.com.zone <!--檢查正向解析區(qū)域配置文件是否正常-->
zone benet.com/IN: loaded serial 2020020910
OK
[root@centos01 ~]# chmod 755 /var/named/benet.com.zone
<!--benet正向解析區(qū)域配置文件添加權(quán)限-->
[root@centos01 ~]# chown named:named /var/named/benet.com.zone
<!--修改屬主屬組-->
[root@centos01 ~]#cp /var/named/benet.com.zone /var/named/accp.com.zone
<!--復(fù)制benet正向解析區(qū)域配置文件到accp正向解析區(qū)域配置文件-->
[root@centos01 ~]# vim /var/named/accp.com.zone
<!--編輯accp正向解析區(qū)域配置文件-->
$TTL 86400
@ SOA accp.com. root.accp.com(
2020020910
1H
15M
1W
1D
)
@ NS centos01.accp.com.
NS centos02.accp.com.
centos01 A 192.168.100.10
ftp A 192.168.100.10
www A 192.168.100.10
[root@centos01 ~]# named-checkzone accp.com /var/named/accp.com.zone
<!--檢查accp正向解析區(qū)域配置文件是否正常-->
zone accp.com/IN: loaded serial 2020020910
OK
[root@centos01 ~]# systemctl start named <!--啟動(dòng)服務(wù)-->
[root@centos01 ~]# systemctl enable named <!--設(shè)置服務(wù)開(kāi)機(jī)自動(dòng)啟動(dòng)-->
[root@centos01 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32 <!--編輯網(wǎng)卡配置文件-->
DNS1=192.168.100.20 <!--添加主DNS(主從互指)-->
DNS2=192.168.100.10 <!--備用DNS-->
[root@centos01 ~]# systemctl restart network <!--重新啟動(dòng)網(wǎng)卡服務(wù)-->
[root@centos01 ~]# systemctl restart named <!--重新啟動(dòng)DNS服務(wù)-->
[root@centos02 ~]# yum -y install bind bind-chroot bind-utils
[root@centos02 ~]# cp /etc/named.conf /etc/named.conf.bak
[root@centos02 ~]# echo "" > /etc/named.conf
[root@centos02 ~]# vim /etc/named.conf
options {
listen-on port 53 { any; };
directory "/var/named";
};
zone "benet.com" IN {
type slave;
file "slaves/benet.com.zone";
masters { 192.168.100.10; };
};
zone "accp.com" IN {
type slave;
file "slaves/accp.com.zone";
masters { 192.168.100.10; };
};
[root@centos02 ~]# systemctl start named
[root@centos02 ~]# systemctl enable named
[root@centos02 ~]# cd /var/named/
[root@centos02 named]# ls
chroot data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@centos02 named]# cd slaves/
[root@centos02 slaves]# ls
accp.com.zone benet.com.zone
[root@centos02 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32
DNS1=192.168.100.10
DNS2=192.168.100.20
[root@centos02 ~]# systemctl restart network
[root@centos02 ~]# systemctl restart named
[root@centos01 ~]# nslookup ftp.benet.com
Server: 192.168.100.20
Address: 192.168.100.20#53
Name: ftp.benet.com
Address: 192.168.100.10
[root@centos02 ~]# nslookup ftp.accp.com
Server: 192.168.100.10
Address: 192.168.100.10#53
Name: ftp.accp.com
Address: 192.168.100.10
[root@centos01 ~]# tar zxvf /mnt/httpd-2.2.17.tar.gz -C /usr/src/
<!--解壓縮apache包-->
[root@centos01 ~]# cd /usr/src/httpd-2.2.17/
[root@centos01 httpd-2.2.17]# ./configure
--prefix=/usr/local/httpd
--enable-so --enable-rewrite
-enable-charset-lite
--enable-cgi
<!--配置Apache-->
[root@centos01 httpd-2.2.17]# make && make install <!--編譯及安裝Apache-->
[root@centos01 ~]# ln -s /usr/local/httpd/bin/* /usr/local/bin/ <!--優(yōu)化Apache執(zhí)行命令-->
[root@centos01 ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
<!--生成Apache服務(wù)-->
[root@centos01 ~]# chmod +x /etc/init.d/httpd <!--添加執(zhí)行權(quán)限-->
[root@centos01 ~]# vim /etc/init.d/httpd <!--修改Apache服務(wù)控制文件-->
#chkconfig:35 80 20
[root@centos01 ~]# chkconfig --add httpd <!--添加系統(tǒng)服務(wù)-->
[root@centos01 ~]# chkconfig --level 35 httpd on<!--設(shè)置開(kāi)機(jī)自動(dòng)啟動(dòng)-->
[root@centos01 ~]# systemctl start httpd <!--啟動(dòng)Apache服務(wù)-->
[root@centos01 ~]# mkdir /var/www <!--創(chuàng)建網(wǎng)站根目錄-->
[root@centos01 ~]# mkdir /var/www/benetcom <!--創(chuàng)建虛擬站點(diǎn)根目錄-->
[root@centos01 ~]# mkdir /var/www/accpcom<!--創(chuàng)建虛擬站點(diǎn)根目錄-->
[root@centos01 ~]# echo "www.benet.com" > /var/www/benetcom/index.html
<!--設(shè)置網(wǎng)站主頁(yè)-->
[root@centos01 ~]# echo "www.accp.com" > /var/www/accpcom/index.html
<!--設(shè)置網(wǎng)站主頁(yè)-->
[root@centos01 ~]# vim /usr/local/httpd/conf/httpd.conf
<!--編制apache主配置文件-->
98 ServerName 192.168.100.10:80 <!--apache服務(wù)器IP地址-->
389 Include conf/extra/httpd-vhosts.conf <!--支持虛擬主機(jī)-->
[root@centos01 ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf <!--編輯虛擬主機(jī)配置文件-->
NameVirtualHost 192.168.100.10:80 <!--虛擬主機(jī)IP地址-->
<Directory "/var/www/">
Order allow,deny
allow from all
</Directory>
<VirtualHost www.benet.com:80> <!--虛擬主機(jī)域名-->
DocumentRoot "/var/www/benetcom/" <!--網(wǎng)站根目錄-->
ServerName www.benet.com <!--網(wǎng)站域名-->
CustomLog "logs/www.benet.com_access_log" common
<!--訪問(wèn)成功日志-->
</VirtualHost>
<VirtualHost www.accp.com:80>
DocumentRoot "/var/www/accpcom/"
ServerName www.accp.com
CustomLog "logs/www.accp.com_access_log" common
</VirtualHost>
[root@centos01 ~]# systemctl restart httpd <!--重新啟動(dòng)httpd服務(wù)-->
[root@centos01 ~]# httpd -t <!--檢查Apache服務(wù)配置文件是否正常-->
Syntax OK
—————— 本文至此結(jié)束,感謝閱讀 ——————
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。