DNS与HTTP综合服务

发布时间:2024年01月19日

以学号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

[root@localhost ~]# firewall-cmd --reload

文章来源:https://blog.csdn.net/lopowh/article/details/135627367
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。