2011-11-30 130 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