Wamp 服务器:多个虚拟主机无法在 Windows 上运行

发布于 2024-08-26 09:45:49 字数 648 浏览 4 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

意中人 2024-09-02 09:45:49

我猜您在某处缺少 NameVirtualHost 127.0.0.1:80 行:)

I'm guessing you're missing the NameVirtualHost 127.0.0.1:80 line somewhere :)

撩发小公举 2024-09-02 09:45:49

我做了这样的事情
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- 对于任何其他本地域

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>

I did some thing like this
1- for the local host its :

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

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>
深居我梦 2024-09-02 09:45:49

您不必将虚拟主机信息写入httpd.conf。只需取消加载 conf/extra/httpd-vhosts.conf 行的注释,然后转到此文件并将您的信息放在那里。应该有效。

我的 httpd-vhosts.conf 示例:

NameVirtualHost *:80

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

You don't have to write virtual host info into httpd.conf. Just uncomment line on which you load conf/extra/httpd-vhosts.conf, then go to this file and put your info there. Should work.

Example of my httpd-vhosts.conf:

NameVirtualHost *:80

<VirtualHost 127.0.0.1>
    DocumentRoot "C:/wamp/www"
    ServerName dev
</VirtualHost>
三生殊途 2024-09-02 09:45:49

您需要包含类似于以下行的内容

NameVirtualHost *

另外,您似乎正在使用 https 连接到服务器,由于 SSL 协议限制,该连接不能与虚拟主机很好地配合。 http 请求中的 Host 标头是加密的,当 apache 解密它时,它已经将请求传递到其中一台虚拟主机。

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. 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.

为人所爱 2024-09-02 09:45:49

我改变了

名称虚拟主机 *:80

名称VirtualHost 127.0.0.1:80

它对我有用

I changed

NameVirtualHost *:80

to

NameVirtualHost 127.0.0.1:80

and it works for me

焚却相思 2024-09-02 09:45:49

不要忘记在 httpd.conf 中检查诸如 "Listen [::0]:80" 之类的行,并在其中添加您的端口,如果 NameVirtualHost< /代码> 不起作用。

Don't forget to check for lines like "Listen [::0]:80" in httpd.conf and add your ports there too, if NameVirtualHost doesn't work.

触ぅ动初心 2024-09-02 09:45:49

大家好,我写了一个非常简单的教程,其中包括整个过程。如果您在评论中遇到任何问题,请告诉我。

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文