以学号22为例:
- 虚拟机初始化
开启防火墙
[root@localhost ~]# systemctl start firewalld
设置IP地址:192.168.22.1
配置YUM源
关闭SELINUX
二、安装软件
[root@localhost ~]# yum -y install bind
[root@localhost ~]# yum -y install httpd
三、配置DNS
[root@localhost ~]# vim /etc/named.conf
allow-query { 192.168.22.0/24; };
[root@localhost ~]# vim /etc/named.rfc1912.zones
zone "whyzj22.com" IN {
type master;
file "whyzj22.com.zone";
allow-update { none; };
};
zone "wh22.com" IN {
type master;
file "wh22.com.zone";
allow-update { none; };
};
zone "22.168.192.in-addr.arpa" IN {
type master;
file "192.168.22.zone";
allow-update { none; };
};
[root@localhost ~]# cd /var/named/
[root@localhost named]# cp -p named.localhost whyzj22.com.zone
[root@localhost named]# cp -p named.loopback 192.168.22.zone
[root@localhost named]# vim whyzj22.com.zone
ns A 192.168.22.1
www A 192.168.22.1
[root@localhost named]# vim 192.168.22.zone
1 PTR ns.whyzj22.com.
1 PTR www.whyzj22.com.
1 PTR ns.wh22.com.
1 PTR www.wh22.com.
[root@localhost named]# cp -p whyzj22.com.zone wh22.com.zone
[root@localhost named]# systemctl restart named
测试一下:
[root@localhost named]# nslookup
> ns.whyzj22.com
Server: 192.168.22.1
Address: 192.168.22.1#53
Name: ns.whyzj22.com
Address: 192.168.22.1
> ns.wh22.com
Server: 192.168.22.1
Address: 192.168.22.1#53
Name: ns.wh22.com
Address: 192.168.22.1
> www.whyzj22.com
Server: 192.168.22.1
四、配置WEB
1、添加用户和设置访问WEB的密码
[root@localhost ~]# useradd yzj
[root@localhost ~]# htpasswd -c /etc/httpd/conf/.htpasswd yzj
New password:
Re-type new password:
Adding password for user yzj
2、建立目录和主页
[root@localhost ~]# mkdir /web1
[root@localhost ~]# mkdir /share
[root@localhost ~]#
[root@localhost ~]# vim /web1/index.html
[root@localhost ~]# vim /share/index.html
[root@localhost ~]#
3、修改虚拟主机的配置文件
[root@localhost ~]# cp /usr/share/doc/httpd/httpd-vhosts.conf /etc/httpd/conf.d/
[root@localhost ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/web1"
ServerName www.whyzj22.com
<Directory "/web1">
AllowOverride None
Require all granted
</Directory>
ServerAlias www.dummy-host.example.com
ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"
CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/share"
ServerName www.wh22.com
<Directory "/share">
AllowOverride all
Authtype basic
Authname "welcome to my site"
Authuserfile /etc/httpd/conf/.htpasswd
Require user yzj
</Directory>
ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"
CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common
</VirtualHost>
重启服务
[root@localhost ~]# systemctl restart httpd.service
五、配置防火墙
[root@localhost ~]# firewall-cmd --zone=public --add-service=dns --permanent
[root@localhost ~]# firewall-cmd --zone=public --add-service=http --permanent文章来源:https://www.toymoban.com/news/detail-808144.html
[root@localhost ~]# firewall-cmd --reload文章来源地址https://www.toymoban.com/news/detail-808144.html
到了这里,关于DNS与HTTP综合服务的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!