2011-11-30 203 views
0

我的Windows計算機上安裝了WAMP。主機文件和虛擬服務器

我想建立幾個虛擬服務器,在以下地址:

127.0.0.1 to localhost/website1/ 
127.0.0.2 to localhost/website2/ 

這裏是我的主機文件的內容:

# Copyright (c) 1993-2009 Microsoft Corp. 
# 
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows. 
# 
# This file contains the mappings of IP addresses to host names. Each 
# entry should be kept on an individual line. The IP address should 
# be placed in the first column followed by the corresponding host name. 
# The IP address and the host name should be separated by at least one 
# space. 
# 
# Additionally, comments (such as these) may be inserted on individual 
# lines or following the machine name denoted by a '#' symbol. 
# 
# For example: 
# 
#  102.54.94.97  rhino.acme.com   # source server 
#  38.25.63.10  x.acme.com    # x client host 

# localhost name resolution is handled within DNS itself. 
# 127.0.0.1  localhost 
# ::1    localhost 
127.0.0.1 localhost/website1 
127.0.0.2 localhost/website2 

但他們都不工作。這兩個地址只是將我引向本地主機ROOT。

如果我訪問http://localhost/website1http://localhost/website2他們都工作。

我做錯了什麼?

我完全靈活的IP地址。

回答

1

您需要將虛擬主機添加到的httpd-vhosts.conf 實例添加(Apache服務器,它位於這樣WAMP \ BIN \ apache的\ Apache2.2.11 \的conf \額外的一個文件夾內的)虛擬主機在該文件中。 您可能還需要從下面的行取消註釋(刪除#符號)在的httpd.conf文件

Include conf/extra/httpd-vhosts.conf 
+0

感謝您的答覆。這是否和我在我的主機文件中一樣? – Luke

+0

是的,除了這樣做外,您還需要更新您的主機文件。我不知道什麼是IP 127.0.0.2的機器。如上所述,我通常在httpd-vhosts.conf中定義虛擬主機,然後將這些虛擬主機網址與本地機器IP 127.0.0.1相匹配。假設您有一臺名爲「mywebiste1」的虛擬主機,那麼您需要將「127.0.0.1 mywebsite1」添加到您的主機文件中。 –

+0

偉大的東西,它現在工作完美,謝謝! – Luke