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/website1或http://localhost/website2他們都工作。
我做錯了什麼?
我完全靈活的IP地址。
感謝您的答覆。這是否和我在我的主機文件中一樣? – Luke
是的,除了這樣做外,您還需要更新您的主機文件。我不知道什麼是IP 127.0.0.2的機器。如上所述,我通常在httpd-vhosts.conf中定義虛擬主機,然後將這些虛擬主機網址與本地機器IP 127.0.0.1相匹配。假設您有一臺名爲「mywebiste1」的虛擬主機,那麼您需要將「127.0.0.1 mywebsite1」添加到您的主機文件中。 –
偉大的東西,它現在工作完美,謝謝! – Luke