Apache 本地主机的NameVirtualHost指令警告
我已经阅读了许多文章,并在相同的IP地址上为2个站点配置了WAMP,如下所示(httpd.conf extract):Apache 本地主机的NameVirtualHost指令警告,apache,wamp,Apache,Wamp,我已经阅读了许多文章,并在相同的IP地址上为2个站点配置了WAMP,如下所示(httpd.conf extract): #告诉Apache按名称识别哪个站点 名称虚拟主机*:80 #告诉Apache将默认WAMP服务器页面服务于“localhost” 服务器名本地主机 DocumentRoot“C:/wamp/www” #告诉Apache 1站点的配置 ServerName client1.localhost DocumentRoot“C:/wamp/www_client1” 通融 命令允许,拒
#告诉Apache按名称识别哪个站点
名称虚拟主机*:80
#告诉Apache将默认WAMP服务器页面服务于“localhost”
服务器名本地主机
DocumentRoot“C:/wamp/www”
#告诉Apache 1站点的配置
ServerName client1.localhost
DocumentRoot“C:/wamp/www_client1”
通融
命令允许,拒绝
允许超越所有
DirectoryIndex.html index.php
#告诉Apache 2站点的配置
ServerName client2.localhost
DocumentRoot“C:/wamp/www_client2”
通融
命令允许,拒绝
允许超越所有
我还将Windows主机文件更改为添加127.0.0.1 client1.localhost等。但是,当我重新启动WAMP服务时,//client1.localhost和//client2.localhost将转到c:\WAMP\www文件夹中的默认站点
非常感谢您的帮助。您是否已将vhosts.conf包含在httpd.conf中 取消注释httpd.conf底部附近的此行(以“Include”开头):
# Virtual hosts - leave this commented
Include conf/extra/httpd-vhosts.conf
编辑:
问题似乎是NameVirtualHost
和VirtualHost
必须匹配,因此不能有NameVirtualHost*:80
和VirtualHost 127.0.0.1
。相反,请使用NameVirtualHost*:80
和VirtualHost*:80
或NameVirtualHost 127.0.0.1:80
和VirtualHost 127.0.0.1
如果它们不匹配,您将看到注释中提到的行为,其中与其他虚拟主机不匹配的虚拟主机将被命中,或者如果它们都相同,则第一个主机(默认本地主机)将被命中
查看本文了解更多信息:尝试一下这种配置,它只是您的一些次要MOD
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
## must be first so the the wamp menu page loads
<VirtualHost *:80>
ServerAdmin webmaster@homemail.net
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
#Tell Apache configuration for 1 site
<VirtualHost *:80>
ServerName client1.localhost
DocumentRoot "C:/wamp/www_client1"
<Directory "C:/wamp/www_client1">
AllowOverride All
order Allow,Deny
Allow from all
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
#Tell Apache configuration for 2 site
<VirtualHost *:80>
ServerName client2.localhost
DocumentRoot "C:/wamp/www_client2"
<Directory "C:/wamp/www_client2">
AllowOverride All
order Allow,Deny
Allow from all
</Directory>
#
#使用基于名称的虚拟主机。
#
名称虚拟主机*:80
##必须是第一个,以便加载wamp菜单页面
服务器管理员webmaster@homemail.net
DocumentRoot“C:/wamp/www”
服务器名本地主机
服务器别名本地主机
命令拒绝,允许
全盘否定
允许从127.0.0.1开始
#告诉Apache 1站点的配置
ServerName client1.localhost
DocumentRoot“C:/wamp/www_client1”
允许超越所有
命令允许,拒绝
通融
DirectoryIndex.html index.php
#告诉Apache 2站点的配置
ServerName client2.localhost
DocumentRoot“C:/wamp/www_client2”
允许超越所有
命令允许,拒绝
通融
所以你会得到一个警告。。。你读过了吗?它说了什么?警告消息是标准的“Virtualhost 127.0.0.1:80与Virtualhost 127.0.0.1:80重叠,第一个优先。也许您需要一个virtualnamehost指令”我有,但是我需要在httpd-vhosts.conf文件中添加任何内容吗?非常感谢。你的代码看起来很好,只是看起来没有被使用。我知道您说过您包含的代码来自httpd.conf——我假设这是一个输入错误,但是这段代码实际上是在httpd.conf中,而不是在httpd vhosts.conf中吗?我必须测试的唯一示例是将所有虚拟主机信息保存在httpd-vhosts.conf文件中。我会尝试将您包含的代码移到此文件中-我不知道它是否能解决您的问题,但即使它不能解决问题,这也是一个好主意。你也可以试着把127.0.0.1改成*:80——这两个版本对我来说都很有用,但你显然有点不对劲。确保在所有这些之后重新启动Apache。。。我知道你说过你是,但很容易忘记。好的,谢谢。。我将删除代码并将其放入httpd-vhosts.conf文件中,看看会发生什么……我已将代码从httpd.conf移动到httpd-vhosts.conf,现在收到以下消息:网站拒绝显示此网页HTTP 403最可能的原因:•此网站要求您登录。您可以尝试的是:返回上一页。更多信息此错误(HTTP 403禁止)意味着Internet Explorer能够连接到该网站,但它没有查看该网页的权限。有关HTTP错误的更多信息,请参阅帮助。
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
## must be first so the the wamp menu page loads
<VirtualHost *:80>
ServerAdmin webmaster@homemail.net
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
#Tell Apache configuration for 1 site
<VirtualHost *:80>
ServerName client1.localhost
DocumentRoot "C:/wamp/www_client1"
<Directory "C:/wamp/www_client1">
AllowOverride All
order Allow,Deny
Allow from all
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
#Tell Apache configuration for 2 site
<VirtualHost *:80>
ServerName client2.localhost
DocumentRoot "C:/wamp/www_client2"
<Directory "C:/wamp/www_client2">
AllowOverride All
order Allow,Deny
Allow from all
</Directory>