标签:charset 系统 ons 虚拟站点 apache dns主从复制 ftp服务 执行命令 技术
一、安装主DNS服务器[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 <!--清空主配置文件内容->
[root@centos01 ~]# vim /etc/named.conf <!--编辑主配置文件-->
options{ <!--全局配置文件-->
listen-on port 53 { any; }; <!--53号端口监听所有IP地址-->
directory "/var/named"; <!--区域配置文件位置-->
};
zone "benet.com" IN { <!--正向解析区域名称-->
type master; <!--主DNS服务器-->
file "benet.com.zone"; <!--正向解析区域配置文件名字-->
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 <!--检查主配置文件是否错误-->
[root@centos01 ~]# vim /var/named/benet.com.zone <!--编制benet的正向解析配置文件-->
$TTL 86400 <!--解析资源记录有效时间24小时-->
@ SOA benet.com. root.benet.com( <!--域名为benet.com-->
2020020910 <!--更新序列号-->
1H <!--刷新时间1小时-->
15M <!--重试时间15分钟-->
1W <!--失效时间1周-->
1D <!--无效解析记录保存时间1天-->
)
@ NS centos01.benet.com. <!--主权威服务器是DNS完全合格域名-->
NS centos02.benet.com. <!--备-->
centos01 A 192.168.100.10 <!--记录正向解析条目-->
centos02 A 192.168.100.20 <!--记录正向解析条目-->
ftp A 192.168.100.10 <!--ftp服务器IP地址-->
www A 192.168.100.10 <!--网站服务器IP地址-->
[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
<!--benet正向解析区域配置文件添加权限-->
[root@centos01 ~]# chown named:named /var/named/benet.com.zone
<!--修改属主属组-->
[root@centos01 ~]#cp /var/named/benet.com.zone /var/named/accp.com.zone
<!--复制benet正向解析区域配置文件到accp正向解析区域配置文件-->
[root@centos01 ~]# vim /var/named/accp.com.zone
<!--编辑accp正向解析区域配置文件-->
$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正向解析区域配置文件是否正常-->
zone accp.com/IN: loaded serial 2020020910
OK
[root@centos01 ~]# systemctl start named <!--启动服务-->
[root@centos01 ~]# systemctl enable named <!--设置服务开机自动启动-->
[root@centos01 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32 <!--编辑网卡配置文件-->
DNS1=192.168.100.20 <!--添加主DNS(主从互指)-->
DNS2=192.168.100.10 <!--备用DNS-->
[root@centos01 ~]# systemctl restart network <!--重新启动网卡服务-->
[root@centos01 ~]# systemctl restart named <!--重新启动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; };
};
[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/ <!--优化Apache执行命令-->
[root@centos01 ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
<!--生成Apache服务-->
[root@centos01 ~]# chmod +x /etc/init.d/httpd <!--添加执行权限-->
[root@centos01 ~]# vim /etc/init.d/httpd <!--修改Apache服务控制文件-->
#chkconfig:35 80 20
[root@centos01 ~]# chkconfig --add httpd <!--添加系统服务-->
[root@centos01 ~]# chkconfig --level 35 httpd on<!--设置开机自动启动-->
[root@centos01 ~]# systemctl start httpd <!--启动Apache服务-->
[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
<!--编制apache主配置文件-->
98 ServerName 192.168.100.10:80 <!--apache服务器IP地址-->
389 Include conf/extra/httpd-vhosts.conf <!--支持虚拟主机-->
[root@centos01 ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf <!--编辑虚拟主机配置文件-->
NameVirtualHost 192.168.100.10:80 <!--虚拟主机IP地址-->
<Directory "/var/www/">
Order allow,deny
allow from all
</Directory>
<VirtualHost www.benet.com:80> <!--虚拟主机域名-->
DocumentRoot "/var/www/benetcom/" <!--网站根目录-->
ServerName www.benet.com <!--网站域名-->
CustomLog "logs/www.benet.com_access_log" common
<!--访问成功日志-->
</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 <!--重新启动httpd服务-->
[root@centos01 ~]# httpd -t <!--检查Apache服务配置文件是否正常-->
Syntax OK
—————— 本文至此结束,感谢阅读 ——————
CentOS 7部署DNS主从复制及Apache域名虚拟主机
标签:charset 系统 ons 虚拟站点 apache dns主从复制 ftp服务 执行命令 技术
原文地址:https://blog.51cto.com/14156658/2472695