简体   繁体   English

Wamp 服务器:多个虚拟主机在 Windows 上不起作用

[英]Wamp Server: Multiple Virtual Hosts are not working on Windows

I have two virtual hosts on windows(for example: test1.dev and test2.dev).我在 Windows 上有两个虚拟主机(例如:test1.dev 和 test2.dev)。 But it always load content of test1.dev for both virtual hosts.但它总是为两个虚拟主机加载 test1.dev 的内容。

Following are my files:以下是我的文件:

hosts:主持人:

127.0.0.1    localhost
127.0.0.1    test1.dev
127.0.0.1    test2.dev

httpd.conf: 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 ?有人能认出这个问题吗?

我猜你在某处错过了NameVirtualHost 127.0.0.1:80行:)

I did some thing like this 1- for the local host its :我做了一些这样的事情 1- 对于本地主机:

NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
ServerAlias localhost
DocumentRoot D:/wamp/www
ErrorLog "D:/wamp/www/error.log"
CustomLog D:/wamp/www/access.log common
<Directory "D:/wamp/www">
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_access.c>
    Order allow,deny
    Allow from all
    </IfModule>
</Directory>
</VirtualHost>

2 - and for any other local domain 2 - 对于任何其他本地域

NameVirtualHost zf.local:80
<VirtualHost zf.local:80>
ServerName zf.local
ServerAlias zf.local 
DocumentRoot D:/Workspace/Zend/documentation
ErrorLog "D:/Workspace/Zend/documentation/error.log"
CustomLog D:/Workspace/Zend/documentation/access.log common
<Directory "D:/Workspace/Zend/documentation">
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_access.c>
    Order allow,deny
    Allow from all
    </IfModule>
</Directory>
</VirtualHost>

You don't have to write virtual host info into httpd.conf .您不必将虚拟主机信息写入httpd.conf Just uncomment line on which you load conf/extra/httpd-vhosts.conf , then go to this file and put your info there.只需取消注释您加载conf/extra/httpd-vhosts.conf ,然后转到此文件并将您的信息放在那里。 Should work.应该管用。

Example of my httpd-vhosts.conf :我的httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost 127.0.0.1>
    DocumentRoot "C:/wamp/www"
    ServerName dev
</VirtualHost>

You need to include something similar to following line您需要包含类似于以下行的内容

NameVirtualHost *

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.此外,由于 SSL 协议限制,您似乎正在使用 https 连接到服务器,该连接在虚拟主机上运行不佳。 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. http 请求中的Host标头是加密的,当 apache 解密它时,它已经将请求传递给虚拟主机之一。

I changed我变了

NameVirtualHost *:80名称虚拟主机 *:80

to

NameVirtualHost 127.0.0.1:80名称虚拟主机 127.0.0.1:80

and it works for me它对我有用

如果NameVirtualHost不起作用,请不要忘记在httpd.conf检查"Listen [::0]:80"的行并在那里添加您的端口。

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/ http://www.kintek.com.au/web-design-blog/configuring-multiple-domains-within-wamp-for-local-development/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM