1、安裝dns服務器
[root@localhost ~]# yum -y install bind*
2、修改配置文件
在/etc/named.conf中:
創(chuàng)新互聯(lián)建站專注于麻栗坡網(wǎng)站建設服務及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供麻栗坡營銷型網(wǎng)站建設,麻栗坡網(wǎng)站制作、麻栗坡網(wǎng)頁設計、麻栗坡網(wǎng)站官網(wǎng)定制、微信平臺小程序開發(fā)服務,打造麻栗坡網(wǎng)絡公司原創(chuàng)品牌,更為您提供麻栗坡網(wǎng)站排名全網(wǎng)營銷落地服務。
listen-on port 53 { any; };
allow-query { any; };
然后創(chuàng)建解析:
vim /etc/named.rfc1912.zones
zone "web1.com" IN {
type master;
file "data/web1.com.zone";
};
在/var/named/data/中創(chuàng)建web1.com.zone文件如下
$TTL 3H
@ IN SOA web1.com. root (
20180928 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS @
IN A 192.168.159.130
www IN A 192.168.159.130
3.啟動named服務:
systemctl start named
ps -ef | grep named
顯示啟動成功
4 測試
[root@localhost ~]# nslookup
> web1.com
Server: 192.168.159.130
Address: 192.168.159.130#53
Name: web1.com
Address: 192.168.159.130
5.dns從域設置
vim /etc/named.rfc1912.zones
zone "web1.com" IN {
type slave;
file "slaves/web1.com.zone";
masters { 192.168.159.130;};
};
重啟服務后:
[root@localhost ~]# nslookup
> web1.com
Server: 192.168.159.131
Address: 192.168.159.131#53
Name: web1.com
Address: 192.168.159.130
1安裝HTTP服務
yum -y install httpd
2.編輯配置文件創(chuàng)建兩個虛擬主機
vim /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.159.130:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/host1/
ServerName 192.168.159.130
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost 192.168.159.129:80>
ServerAdmin webmaster@dummy-host.example.com
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/host1/
ServerName 192.168.159.130
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
3.添加一個地址
ip addr add 192.168.159.129 dev ens33
4 編輯主頁文件
[root@localhost conf]# cat /var/www/html/vhost1/index.html
床前明月光
[root@localhost conf]# cat /var/www/html/host1/index.html
日照香爐生紫煙
5 訪問成功
6 配置訪問控制
在相應的地方插入以下哦欸之
<Directory "/var/www/html/vhost1">
options None
AllowOverRide AuthConfig
AuthType Basic
AuthName "wellcome to login .."
AuthBasicProvider file
AuthUserFile /etc/httpd/conf/.htpwd
Require user zhangsan lisi
</Directory>
<Directory "/var/www/html/host1">
options None
AllowOverRide AuthConfig
AuthType Basic
AuthName "wellcome to login .."
AuthBasicProvider file
AuthUserFile /etc/httpd/conf/.htpwd
Require user zhangsan lisi
</Directory>
創(chuàng)建用戶密碼
htpasswd -c -m /etc/httpd/conf/.htpwd zhangsan
htpasswd -m /etc/httpd/conf/.htpwd lisi
htpasswd -m /etc/httpd/conf/.htpwd wangwu
7訪問控制
網(wǎng)頁標題:實現(xiàn)DNS主從域,http虛擬主機跟用戶
轉(zhuǎn)載來于:http://www.chinadenli.net/article42/iijehc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供、標簽優(yōu)化、網(wǎng)頁設計公司、移動網(wǎng)站建設、商城網(wǎng)站、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)