DNS与HTTP综合服务

以学号22为例:

DNS与HTTP综合服务_第1张图片

  • 虚拟机初始化

开启防火墙

[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

    ServerAdmin [email protected]

    DocumentRoot "/web1"

    ServerName www.whyzj22.com

        

            AllowOverride None

            Require all granted

        

    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

    ServerAdmin [email protected]

    DocumentRoot "/share"

    ServerName www.wh22.com

        

            AllowOverride all

            Authtype basic

            Authname "welcome to my site"

            Authuserfile /etc/httpd/conf/.htpasswd

            Require user yzj

         

    ErrorLog "/var/log/httpd/dummy-host.example.com-error_log"

    CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common

重启服务

[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

你可能感兴趣的:(linux,apache,linux,运维)