您好,登錄后才能下訂單哦!
(1)基于域名
(2)基于端口
(3)基于IP
在同一臺物理服務(wù)器中運(yùn)行多個(gè)web站點(diǎn),其中每一個(gè)站點(diǎn)并不獨(dú)立占用一臺真正的計(jì)算機(jī)
(1)基于域名的虛擬主機(jī)
(2)基于IP地址的虛擬主機(jī)
(3)基于端口的虛擬主
(1)KeepAlive
是否打開連接保持,OFF關(guān)閉,ON 打開
(2)KeepAlive Timeout
一次連接多粗請求之間的最大間隔時(shí)間,兩次請求超過該時(shí)間連接斷開
(3)MaxKeepAliveRequests
一次連接能夠傳輸?shù)淖畲笳埱髷?shù)量
(1)作用
控制對網(wǎng)站資源的訪問
為特定的網(wǎng)站目錄添加訪問權(quán)限
(2)常用的訪問控制方式
客戶機(jī)地址限制
用戶限制
Require all granted
Require all denied
Require local
Require [not ] host <主機(jī)名或域名列表>
Require [not ] ip <IP地址或網(wǎng)段列表>
使用not禁止訪問時(shí)要將其置于<RequireAll></RequireAll>容器中并在容器中指定相應(yīng)的限制策略
Require的命令模式
安裝DNS 和httpd 服務(wù)
[root@localhost ~]# yum install bind httpd -y
修改DNS 主配置文件
[root@localhost ~]# vim /etc/named.conf
配置DNS區(qū)域配置文件
[root@localhost ~]# vim /etc/named.rfc1912.zones
#在區(qū)域配置文件中添加下列內(nèi)容
zone "kgc.com" IN {
type master;
file "kgc.com.zone";
allow-update { none; };
};
zone "accp.com" IN {
type master;
file "accp.com.zone";
allow-update { none; };
};
配置DNS 區(qū)域數(shù)據(jù)配置文件
[root@localhost ~]# cd /var/named/
[root@localhost named]# ls //查看
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p named.localhost kgc.com.zone
[root@localhost named]# vim kgc.com.zon
將kgc的區(qū)域數(shù)據(jù)配置文件,復(fù)制一份復(fù)制到accp下不做修改
[root@localhost named]# cp -p kgc.com.zone accp.com.zone
開啟DNS服務(wù)、關(guān)閉防火墻和安全功能
[root@localhost named]# systemctl start named
[root@localhost named]# systemctl stop firewalld.service
[root@localhost named]# setenforce 0
在windows10 上打開cmd測試是否能解析到域名
[root@localhost named]# cd /etc/httpd/
[root@localhost httpd]# ls
conf conf.d conf.modules.d logs modules run
[root@localhost httpd]# cd conf/
[root@localhost conf]# ls
httpd.conf magic
[root@localhost conf]# mkdir extra
[root@localhost conf]# cd extra/
[root@localhost extra]# vim vhost.conf //創(chuàng)建擴(kuò)展文件
<VirtualHost *:80> //標(biāo)題,固定格式
DocumentRoot "/var/www/html/kgc" //站點(diǎn)
ServerName www.kgc.com //域名
ErrorLog "logs/www.kgc.com.error_log" //錯(cuò)誤日志文件
CustomLog "logs/www.kgc.com.access_log" common //訪問日志文件
<Directory "/var/www/html/">
Require all granted //訪問權(quán)限
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/html/accp"
ServerName www.accp.com
ErrorLog "logs/www.accp.com.error_log"
CustomLog "logs/www.accp.com.access_log" common
<Directory "/var/www/html/">
Require all granted
</Directory>
</VirtualHost>
配置網(wǎng)頁顯示內(nèi)容
[root@localhost httpd]# cd /var/www/html/
[root@localhost html]# ls
[root@localhost html]# mkdir kgc accp
[root@localhost html]# ls
accp kgc
[root@localhost html]# cd kgc/
[root@localhost kgc]# vim index.html
<h2>this is kgc web</h2>
[root@localhost kgc]# cd ../accp/
[root@localhost accp]# vim index.html
<h2>this is accp web</h2>
配置網(wǎng)頁的絕對路徑
[root@localhost accp]# cd /etc/httpd/
[root@localhost httpd]# ls
conf conf.d conf.modules.d logs modules run
[root@localhost httpd]# cd conf/
[root@localhost conf]# vim httpd.conf
Include conf/extra/vhost.conf
啟動(dòng)http服務(wù)
[root@localhost conf]# systemctl start httpd
進(jìn)入擴(kuò)展文件,配置,添加一個(gè)端口
[root@localhost conf]# cd extra/
[root@localhost extra]# vim vhost.conf
<VirtualHost *:8080>
22 DocumentRoot "/var/www/html/accp02"
23 ServerName www.accp.com
24 ErrorLog "logs/www.accp02.com.error_log"
25 CustomLog "logs/www.accp02.com.access_log" common
26 <Directory "/var/www/html/">
27 Require all granted
28 </Directory>
29 </VirtualHost>
[root@localhost extra]# cd /var/www/html/ //創(chuàng)建accp02 zhandian
[root@localhost html]# ls
accp kgc
[root@localhost html]# mkdir accp02
[root@localhost html]# cd accp02/
[root@localhost accp02]# vim index.html
<h2>this is accp02 web</h2>
進(jìn)入絕對路徑,修改
[root@localhost accp02]# vim /etc/httpd/conf/httpd.conf
重啟網(wǎng)頁服務(wù)
[root@localhost accp02]# systemctl restart httpd
查看端口
[root@localhost accp02]# netstat -ntap
基于IP要不同的IP地址,我們首先在虛擬機(jī)上添加一個(gè)網(wǎng)卡,然后讓他自動(dòng)獲取IP地址。
第二塊網(wǎng)卡添加成功,他的IP地址為192.168.45.128
進(jìn)入vhost.conf修改,設(shè)置基IP 的配置
[root@localhost accp02]# cd /etc/httpd/conf/extra/
[root@localhost extra]# vim vhost.conf
1 <VirtualHost 192.168.45.135:80>
2 DocumentRoot "/var/www/html/kgc"
3 ErrorLog "logs/www.kgc.com.error_log"
4 CustomLog "logs/www.kgc.com.access_log" common
5 <Directory "/var/www/html/">
6 Require all granted
7 </Directory>
8 </VirtualHost>
9
10 <VirtualHost 192.168.45.128:80>
11 DocumentRoot "/var/www/html/kgc02"
12 ErrorLog "logs/www.kgc02.com.error_log"
13 CustomLog "logs/www.kgc02.com.access_log" common
14 <Directory "/var/www/html/">
15 Require all granted
16 </Directory>
17 </VirtualHost>
創(chuàng)建網(wǎng)頁文件,并添加網(wǎng)頁顯示內(nèi)容
[root@localhost extra]# cd /var/www/html/
[root@localhost html]# mkdir kgc02
[root@localhost html]# cd kgc02/
[root@localhost kgc02]# vim index.html
<h2>this is kgc02 web</h2>
進(jìn)入http配置文件
[root@localhost kgc02]# vim /etc/httpd/conf/httpd.conf
重啟網(wǎng)頁服務(wù)
[root@localhost kgc02]# systemctl restart httpd
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。