Wamp 服务器:多个虚拟主机无法在 Windows 上运行
我在 Windows 上有两个虚拟主机(例如:test1.dev 和 test2.dev)。但它总是为两个虚拟主机加载 test1.dev 的内容。
以下是我的文件:
主机:
127.0.0.1 localhost
127.0.0.1 test1.dev
127.0.0.1 test2.dev
httpd.conf:
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Include "c:/wamp/alias/*"
<VirtualHost 127.0.0.1>
ServerName test1.dev
DocumentRoot "C:\wamp\www\test1\public"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName test2.dev
DocumentRoot "C:\wamp\www\test2\public"
</VirtualHost>
有人能识别出这个问题吗?
I have two virtual hosts on windows(for example: test1.dev and test2.dev). But it always load content of test1.dev for both virtual hosts.
Following are my files:
hosts:
127.0.0.1 localhost
127.0.0.1 test1.dev
127.0.0.1 test2.dev
httpd.conf:
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Include "c:/wamp/alias/*"
<VirtualHost 127.0.0.1>
ServerName test1.dev
DocumentRoot "C:\wamp\www\test1\public"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName test2.dev
DocumentRoot "C:\wamp\www\test2\public"
</VirtualHost>
Can someone recognize the problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我猜您在某处缺少
NameVirtualHost 127.0.0.1:80
行:)I'm guessing you're missing the
NameVirtualHost 127.0.0.1:80
line somewhere :)我做了这样的事情
1- 对于本地主机:
2- 对于任何其他本地域
I did some thing like this
1- for the local host its :
2 - and for any other local domain
您不必将虚拟主机信息写入
httpd.conf
。只需取消加载conf/extra/httpd-vhosts.conf
行的注释,然后转到此文件并将您的信息放在那里。应该有效。我的
httpd-vhosts.conf
示例:You don't have to write virtual host info into
httpd.conf
. Just uncomment line on which you loadconf/extra/httpd-vhosts.conf
, then go to this file and put your info there. Should work.Example of my
httpd-vhosts.conf
:您需要包含类似于以下行的内容
另外,您似乎正在使用 https 连接到服务器,由于 SSL 协议限制,该连接不能与虚拟主机很好地配合。 http 请求中的 Host 标头是加密的,当 apache 解密它时,它已经将请求传递到其中一台虚拟主机。
You need to include something similar to following line
Also, it seems you are using https connection to the server which doesn't play well with virtual hosts because of the SSL protocol limitation. The
Host
header in the http request is encrypted and by the time apache decrypts it, it has already passed on the request to one of the virtual host.我改变了
到
它对我有用
I changed
to
and it works for me
不要忘记在
httpd.conf
中检查诸如"Listen [::0]:80"
之类的行,并在其中添加您的端口,如果NameVirtualHost< /代码> 不起作用。
Don't forget to check for lines like
"Listen [::0]:80"
inhttpd.conf
and add your ports there too, ifNameVirtualHost
doesn't work.大家好,我写了一个非常简单的教程,其中包括整个过程。如果您在评论中遇到任何问题,请告诉我。
http:// www.kintek.com.au/web-design-blog/configuring-multiple-domains-within-wamp-for-local-development/
Hey guys I've written a very straight forward tutorial which includes the whole process. Let me know if you run into any problems in a comment.
http://www.kintek.com.au/web-design-blog/configuring-multiple-domains-within-wamp-for-local-development/