1、安裝dns服務(wù)器
[root@localhost ~]# yum -y install bind*
2、修改配置文件
在/etc/named.conf中:
創(chuàng)新互聯(lián)建站專(zhuān)注于麻栗坡網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供麻栗坡?tīng)I(yíng)銷(xiāo)型網(wǎng)站建設(shè),麻栗坡網(wǎng)站制作、麻栗坡網(wǎng)頁(yè)設(shè)計(jì)、麻栗坡網(wǎng)站官網(wǎng)定制、微信平臺(tái)小程序開(kāi)發(fā)服務(wù),打造麻栗坡網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供麻栗坡網(wǎng)站排名全網(wǎng)營(yíng)銷(xiāo)落地服務(wù)。
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.啟動(dòng)named服務(wù):
systemctl start named
ps -ef | grep named
顯示啟動(dòng)成功
4 測(cè)試
[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從域設(shè)置
vim /etc/named.rfc1912.zones
zone "web1.com" IN {
type slave;
file "slaves/web1.com.zone";
masters { 192.168.159.130;};
};
重啟服務(wù)后:
[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服務(wù)
yum -y install httpd
2.編輯配置文件創(chuàng)建兩個(gè)虛擬主機(jī)
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.添加一個(gè)地址
ip addr add 192.168.159.129 dev ens33
4 編輯主頁(yè)文件
[root@localhost conf]# cat /var/www/html/vhost1/index.html
床前明月光
[root@localhost conf]# cat /var/www/html/host1/index.html
日照香爐生紫煙
5 訪問(wèn)成功
6 配置訪問(wèn)控制
在相應(yīng)的地方插入以下哦欸之
<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)建用戶(hù)密碼
htpasswd -c -m /etc/httpd/conf/.htpwd zhangsan
htpasswd -m /etc/httpd/conf/.htpwd lisi
htpasswd -m /etc/httpd/conf/.htpwd wangwu
7訪問(wèn)控制
網(wǎng)頁(yè)標(biāo)題:實(shí)現(xiàn)DNS主從域,http虛擬主機(jī)跟用戶(hù)
轉(zhuǎn)載來(lái)于:http://aaarwkj.com/article42/iijehc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、標(biāo)簽優(yōu)化、網(wǎng)頁(yè)設(shè)計(jì)公司、移動(dòng)網(wǎng)站建設(shè)、商城網(wǎng)站、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)