2012-03-26 34 views
0

我想運行多個網站,並且希望每個網站(通過子域區分)指向不同的DocumentRoot。在可變子域Apache2中運行多個網站

我的設置

Host Machine: Mac (Lion) 
Development Machine Ubuntu 10.04 (a vm using VirtualBox) 

從Mac的瀏覽器,我希望能夠訪問

http://website1.dev 
http://website2.dev 

明白,可以給予任何幫助。

注:當我嘗試使用一個服務器名,我得到

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName 

回答

1

你見過或閱讀最新的在線Apache文檔中提供的虛擬主機的例子嗎?關於「在單個IP地址上運行多個基於名稱的網站」的This specific section(列表中的第一個)應該對您有所幫助,這似乎正是您正在嘗試執行的操作。這裏的片段,根據您的需求進行修改:

# Ensure that Apache listens on port 80 
Listen 80 

<VirtualHost *:80> 
    DocumentRoot /www/website1 
    ServerName website1.dev 
    # (Other directives here) 
</VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot /www/website2 
    ServerName website2.dev 
    # (Other directives here) 
</VirtualHost> 

如果這不起作用,您將不得不詳細說明。你的Apache版本是什麼?你目前的httpd.conf和virtualhost.conf文件內容是什麼?

+0

是的。這對我來說很有用。謝謝。 – 2012-04-03 19:54:02