茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1729840 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
PIMG_00212.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2015/9/7 6:57:31

Virtual Host: 如何在同一個 IP (伺服器)上以不同的 Domain Name 架設多個網站

Posted by HP 
「多個網站或 Domain 架在同一個 IP 上」在 Apache 的術語中稱作 Name-based Virtual Host。另外還有 IP-based Virtual Host,不過比較不常用,Name-based Virtual Host 也才是本文的介紹主題 (Name-based 顧名思義即指 Domain Name)。

作法很簡單,若假設 Apache Server 已經正常地運作了,只需修改 httpd.conf 檔案中間的幾個部份。

以下以將 www.example1.comwww.example2.com 架在同一個 Apache Server 底下的設定作為例子。



NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com

# Other directives here / 可於此加入其他所需目錄,例如 CGI Script 的目錄

</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org

# Other directives here

</VirtualHost>


若進來的 HTTP Request 的 ServerName 不是上述二者,以置於前的 www.example1.com 為主。

另請注意:不同的 Linux Distribution 的 Apahce 設定方式略有不同,例如 openSUSE 的設定主要是在

/etc/apache2/default-server.conf(需在檔中(最後)加入 NameVirtualHost *:80),

同時 Virtual Host 的設定是在

/etc/apache2/vhosts.d/*.conf

(需在該目錄新增 .conf 檔,加上上述之 Script)。因此,不同的 Linux Distribution 請注意其中可能的差別,但其原理相同。


Refereces:
Official Page: VirtualHost Examples
Official Paeg:
Name-based Virtual Host Support




原文出處:Virtual Host: 如何在同一個 IP (伺服器)上以不同的 Domain Name 架設多個網站 - Apache HTTP Server論壇 | 美寶論壇 MEPO Forum
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|