Wampserver: 配置 Apache 虛擬機(jī)

  1. 確保 httpd.conf 配置文件,已將引入虛擬機(jī)配置打開(kāi)

Include conf/extra/httpd-vhosts.conf

  1. 打開(kāi) extra/httpd-vhosts.conf,添加上需要添加的 virtualhost

<VirtualHost *:80>
ServerName www.saiku.cc
DocumentRoot D:\workspances
<Directory "D:\workspances">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

  1. How the server selects the proper name-based virtual host .

服務(wù)器如何選擇合適的"name-based virtual host"。
#3.1 It is important to recognize that the first step in name-based virtual host resolution is IP-based resolution.
首先要知道 name-base virtual host 解決方案的第一步,就是通過(guò) IP-based來(lái)解決的。
Name-based virtual host resolution only chooses the most appropriate name-based virtual host after narrowing down the candidates to the best IP-based match. Using a wildcard (*) for the IP address in all of the VirtualHost directives makes this IP-based mapping irrelevant.
#3.2 name-base virtual host 在將匹配范圍縮小,直到匹配到最準(zhǔn)確的 IP。在所有的 VirtualHost 指令中,使用通配符(*)作為 IP 地址,將會(huì)使 IP-based 匹配失效。
When a request arrives, the server will find the best (most specific) matching [<VirtualHost>](http://httpd.apache.org/docs/2.4/en/mod/core.html#virtualhost) argument based on the IP address and port used by the request.
#3.3 當(dāng)一個(gè)請(qǐng)求到達(dá)時(shí),服務(wù)器會(huì)以發(fā)起請(qǐng)求的 IP 地址和端口為基礎(chǔ),找到匹配度最高的參數(shù)。
If there is more than one virtual host containing this best-match address and port combination, Apache will further compare the [ServerName](http://httpd.apache.org/docs/2.4/en/mod/core.html#servername)
and [ServerAlias](http://httpd.apache.org/docs/2.4/en/mod/core.html#serveralias)
directives to the server name present in the request.
#3.4 如果存在多個(gè)虛擬機(jī),都包含了匹配的 IP 地址與端口組合,Apache 會(huì)進(jìn)一步比較 ServerName 指令、ServerAlias 指令與請(qǐng)求中發(fā)送的 server name。
If you omit the [ServerName](http://httpd.apache.org/docs/2.4/en/mod/core.html#servername)
directive from any name-based virtual host, the server will default to a fully qualified domain name (FQDN) derived from the system hostname. This implicitly set server name can lead to counter-intuitive virtual host matching and is discouraged.
#3.5 如果你在任一個(gè) name-based virtual host 中,都沒(méi)使用 ServerName 指令,服務(wù)器默認(rèn)會(huì)使用來(lái)自系統(tǒng) hostname 的全域名。這種隱藏的 server name 設(shè)置會(huì)導(dǎo)致反直覺(jué)的 host 匹配,不鼓勵(lì)這種做法。
詳情參考,官方手冊(cè)地址

  1. Windows 測(cè)試虛擬機(jī)配置命令,進(jìn)入到 /apache_install_path/to/bin/

httpd.exe -S

  1. Check httpd.conf syntax | 檢查配置文件的語(yǔ)法,截圖如下:


    check_httpdconf_syntax.png

提示:

<Directory "F:\projects\trunk"> path is invalid.

** httpd-vhosts.conf ** 配置內(nèi)容:

<VirtualHost *:80>
ServerName www.saiku.cc
DocumentRoot F:\projects\trunk
<Directory "F:\projects\trunk">
#<Directory "D:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc閱讀 2,993評(píng)論 0 0
  • 一、Nagios簡(jiǎn)介 Nagios是一款開(kāi)源的電腦系統(tǒng)和網(wǎng)絡(luò)監(jiān)視工具,能有效監(jiān)控Windows、Linux和Uni...
    1b3bd36d9d21閱讀 8,397評(píng)論 3 13
  • =========================================================...
    lavor閱讀 3,649評(píng)論 0 5
  • 00 序言 本文集專收錄平日遐思,記錄生活瑣事。盡量避免空泛感慨和縹緲情懷,就是一本接地氣的日記冊(cè)子,不要美,要真...
    脊生閱讀 331評(píng)論 1 1
  • 做線上賽的時(shí)候遇見(jiàn)了一道題, 題目:訪問(wèn)http://140.143.191.241:8081,獲得服務(wù)器根目錄下...
    Sund4y閱讀 1,687評(píng)論 0 2

友情鏈接更多精彩內(nèi)容