成都网站建设设计

将想法与焦点和您一起共享

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服务器

创新互联公司主营大冶网站建设的网络公司,主营网站建设方案,成都App制作,大冶h5重庆小程序开发公司搭建,大冶网站营销推广欢迎大冶等地区企业咨询

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服务器

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


网站题目:CentOS7安装主从DNS服务和配置Apache服务器
分享网址:http://chengdu.cdxwcx.cn/article/gshpgg.html