189 8069 5689

CentOS7安装主从DNS服务和配置Apache服务器-创新互联

一、安装主DNS服务器

1、配置主DNS

[root@centos01 ~]# yum -y install bind bind-chroot bind-utils   
[root@centos01 ~]# cp /etc/named.conf /etc/named.conf.bak  
[root@centos01 ~]# echo "" > /etc/named.conf    
options{        
   listen-on  port   53  { any; };    
   directory "/var/named";      
};
zone   "benet.com" IN  {      
   type   master;            
   file   "benet.com.zone";      
   allow-transfer { 192.168.100.20; };    
};
zone   "accp.com"  IN  {
   type   master;
   file   "accp.com.zone";
   allow-transfer  { 192.168.100.20; };
};
[root@centos01 ~]# named-checkconf -z /etc/named.conf  

2、配置benet区域的正向解析区域

[root@centos01 ~]# vim /var/named/benet.com.zone  
$TTL   86400     
@  SOA benet.com.  root.benet.com(    
   2020020910     
   1H       
   15M        
   1W      
   1D       
)
@  NS  centos01.benet.com. 
   NS  centos02.benet.com.        
centos01 A  192.168.100.10     
centos02 A  192.168.100.20     
ftp  A  192.168.100.10      
www A  192.168.100.10      
[root@centos01 ~]# named-checkzone benet.com /var/named/benet.com.zone  
zone benet.com/IN: loaded serial 2020020910
OK
[root@centos01 ~]# chmod 755 /var/named/benet.com.zone     
   
[root@centos01 ~]# chown named:named /var/named/benet.com.zone     
        

3、配置accp区域的正向解析区域

[root@centos01 ~]#cp /var/named/benet.com.zone  /var/named/accp.com.zone   


[root@centos01 ~]# vim /var/named/accp.com.zone
      
$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  
       
zone accp.com/IN: loaded serial 2020020910
OK

4、启动DNS服务

[root@centos01 ~]# systemctl start named       
[root@centos01 ~]# systemctl enable named   

5、网卡添加DNS

[root@centos01 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32       
DNS1=192.168.100.20         
DNS2=192.168.100.10          
[root@centos01 ~]# systemctl restart network    
[root@centos01 ~]# systemctl restart named  

二、安装从DNS服务器

1、配置从DNS

[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; };
};

2、启动DNS服务

[root@centos02 ~]# systemctl start named
[root@centos02 ~]# systemctl enable named

3、检测从是否自动复制主的配置文件

[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

4、网卡添加DNS

[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

5、测试DNS解析

1)主DNS测试解析

[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

2)客户端测试解析

CentOS 7安装主从DNS服务和配置Apache服务器

成都创新互联公司是一家专业提供西和企业网站建设,专注与成都做网站、网站制作、成都外贸网站建设H5建站、小程序制作等业务。10年已为西和众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。

3)备用DNS测试解析

[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

三、配置基于域名的Apache服务器

1、安装配置Apache

[root@centos01 ~]# tar zxvf /mnt/httpd-2.2.17.tar.gz -C /usr/src/ 

[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
     
[root@centos01 httpd-2.2.17]# make && make install 
[root@centos01 ~]# ln -s /usr/local/httpd/bin/* /usr/local/bin/ 
[root@centos01 ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
      
[root@centos01 ~]# chmod +x /etc/init.d/httpd  
[root@centos01 ~]# vim /etc/init.d/httpd  
#chkconfig:35 80 20 
[root@centos01 ~]# chkconfig --add httpd 
[root@centos01 ~]# chkconfig --level 35 httpd on
[root@centos01 ~]# systemctl start httpd  

2、配置虚拟主机

[root@centos01 ~]# mkdir /var/www    
[root@centos01 ~]# mkdir /var/www/benetcom 
[root@centos01 ~]# mkdir /var/www/accpcom
[root@centos01 ~]# echo "www.benet.com" >  /var/www/benetcom/index.html     

[root@centos01 ~]# echo "www.accp.com" >  /var/www/accpcom/index.html     

[root@centos01 ~]# vim /usr/local/httpd/conf/httpd.conf  
     
98 ServerName 192.168.100.10:80 
389 Include conf/extra/httpd-vhosts.conf 
[root@centos01 ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf     
NameVirtualHost 192.168.100.10:80    


     Order  allow,deny
     allow  from   all
 

    
   DocumentRoot "/var/www/benetcom/"  
   ServerName www.benet.com       
   CustomLog "logs/www.benet.com_access_log" common  
          


   DocumentRoot "/var/www/accpcom/"
   ServerName www.accp.com
   CustomLog "logs/www.accp.com_access_log" common

[root@centos01 ~]# systemctl restart httpd 
[root@centos01 ~]# httpd -t 
Syntax OK

3、客户端访问测试

CentOS 7安装主从DNS服务和配置Apache服务器

CentOS 7安装主从DNS服务和配置Apache服务器

—————— 本文至此结束,感谢阅读 ——————

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章名称:CentOS7安装主从DNS服务和配置Apache服务器-创新互联
标题路径:http://cdxtjz.cn/article/cceejg.html

其他资讯