CentOS 7部署DNS主从复制及Apache域名虚拟主机
2021-06-04 10:04
标签:charset 系统 ons 虚拟站点 apache dns主从复制 ftp服务 执行命令 技术 —————— 本文至此结束,感谢阅读 —————— CentOS 7部署DNS主从复制及Apache域名虚拟主机 标签:charset 系统 ons 虚拟站点 apache dns主从复制 ftp服务 执行命令 技术 原文地址:https://blog.51cto.com/14156658/24726951、配置主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)客户端测试解析
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
3、客户端访问测试
文章标题:CentOS 7部署DNS主从复制及Apache域名虚拟主机
文章链接:http://soscw.com/index.php/essay/90355.html