以学号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
[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
[root@localhost ~]# useradd yzj
[root@localhost ~]# htpasswd -c /etc/httpd/conf/.htpasswd yzj
New password:
Re-type new password:
Adding password for user yzj
[root@localhost ~]# mkdir /web1
[root@localhost ~]# mkdir /share
[root@localhost ~]#
[root@localhost ~]# vim /web1/index.html
[root@localhost ~]# vim /share/index.html
[root@localhost ~]#
[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