主机文件和虚拟服务器

时间:2011-11-30 08:53:27

标签: windows host virtual-server

我的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

但它们似乎都不起作用。这两个地址只是引导我进入localhost ROOT。

如果我访问http://localhost/website1http://localhost/website2,他们都会工作。

我做错了吗?

我对IP地址非常灵活。

1 个答案:

答案 0 :(得分:1)

您需要将虚拟主机添加到 httpd-vhosts.conf (apache服务器,它位于像wamp \ bin \ apache \ Apache2.2.11 \ conf \ extra这样的文件夹中) 添加虚拟主机的示例位于该文件中。 您还可能需要从 httpd.conf 文件中的以下行取消注释(删除#符号)

Include conf/extra/httpd-vhosts.conf