oLeiShen 2020-02-21
[ ~]# yum -y install bind bind-chroot bind-utils <!--安装DNS依赖程序--> [ ~]# cp /etc/named.conf /etc/named.conf.bak <!--备份主配置文件--> [ ~]# echo "" > /etc/named.conf <!--清空主配置文件内容-> [ ~]# 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; }; }; [ ~]# named-checkconf -z /etc/named.conf <!--检查主配置文件是否错误-->
[ ~]# 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地址--> [ ~]# named-checkzone benet.com /var/named/benet.com.zone <!--检查正向解析区域配置文件是否正常--> zone benet.com/IN: loaded serial 2020020910 OK [ ~]# chmod 755 /var/named/benet.com.zone <!--benet正向解析区域配置文件添加权限--> [ ~]# chown named:named /var/named/benet.com.zone <!--修改属主属组-->
[ ~]#cp /var/named/benet.com.zone /var/named/accp.com.zone <!--复制benet正向解析区域配置文件到accp正向解析区域配置文件--> [ ~]# 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 [ ~]# named-checkzone accp.com /var/named/accp.com.zone <!--检查accp正向解析区域配置文件是否正常--> zone accp.com/IN: loaded serial 2020020910 OK
[ ~]# systemctl start named <!--启动服务--> [ ~]# systemctl enable named <!--设置服务开机自动启动-->
[ ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32 <!--编辑网卡配置文件--> DNS1=192.168.100.20 <!--添加主DNS(主从互指)--> DNS2=192.168.100.10 <!--备用DNS--> [ ~]# systemctl restart network <!--重新启动网卡服务--> [ ~]# systemctl restart named <!--重新启动DNS服务-->
[ ~]# yum -y install bind bind-chroot bind-utils [ ~]# cp /etc/named.conf /etc/named.conf.bak [ ~]# echo "" > /etc/named.conf [ ~]# 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; }; };
[ ~]# systemctl start named [ ~]# systemctl enable named
[ ~]# cd /var/named/ [ named]# ls chroot data dynamic named.ca named.empty named.localhost named.loopback slaves [ named]# cd slaves/ [ slaves]# ls accp.com.zone benet.com.zone
[ ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32 DNS1=192.168.100.10 DNS2=192.168.100.20 [ ~]# systemctl restart network [ ~]# systemctl restart named
[ ~]# nslookup ftp.benet.com Server: 192.168.100.20 Address: 192.168.100.20#53 Name: ftp.benet.com Address: 192.168.100.10
[ ~]# nslookup ftp.accp.com Server: 192.168.100.10 Address: 192.168.100.10#53 Name: ftp.accp.com Address: 192.168.100.10
[ ~]# tar zxvf /mnt/httpd-2.2.17.tar.gz -C /usr/src/ <!--解压缩apache包--> [ ~]# cd /usr/src/httpd-2.2.17/ [ httpd-2.2.17]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite -enable-charset-lite --enable-cgi <!--配置Apache--> [ httpd-2.2.17]# make && make install <!--编译及安装Apache--> [ ~]# ln -s /usr/local/httpd/bin/* /usr/local/bin/ <!--优化Apache执行命令--> [ ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd <!--生成Apache服务--> [ ~]# chmod +x /etc/init.d/httpd <!--添加执行权限--> [ ~]# vim /etc/init.d/httpd <!--修改Apache服务控制文件--> #chkconfig:35 80 20 [ ~]# chkconfig --add httpd <!--添加系统服务--> [ ~]# chkconfig --level 35 httpd on<!--设置开机自动启动--> [ ~]# systemctl start httpd <!--启动Apache服务-->
[ ~]# mkdir /var/www <!--创建网站根目录--> [ ~]# mkdir /var/www/benetcom <!--创建虚拟站点根目录--> [ ~]# mkdir /var/www/accpcom<!--创建虚拟站点根目录--> [ ~]# echo "www.benet.com" > /var/www/benetcom/index.html <!--设置网站主页--> [ ~]# echo "www.accp.com" > /var/www/accpcom/index.html <!--设置网站主页--> [ ~]# vim /usr/local/httpd/conf/httpd.conf <!--编制apache主配置文件--> 98 ServerName 192.168.100.10:80 <!--apache服务器IP地址--> 389 Include conf/extra/httpd-vhosts.conf <!--支持虚拟主机--> [ ~]# 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> [ ~]# systemctl restart httpd <!--重新启动httpd服务--> [ ~]# httpd -t <!--检查Apache服务配置文件是否正常--> Syntax OK
—————— 本文至此结束,感谢阅读 ——————