我已经设置了WAMP服务器,它运行正常 然后我尝试使用它的虚拟主机,它不起作用
在httpd.conf文件中我添加了这些行
Listen 8081
Listen 8082
Include conf/extra/httpd-vhosts.conf
在httpd-vhosts.conf中
NameVirtualHost *:80
Listen 8081
Listen 8082
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.localhost
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.localhost"
ServerName dummy-host.localhost
ServerAlias www.dummy-host.localhost
ErrorLog "logs/dummy-host.localhost-error.log"
CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost>
<VirtualHost localhost:8081>
ServerName localhost:8081
DocumentRoot "D:/wamp/www/project/"
Alias /index.html D:/wamp/www/project/index.php
</VirtualHost>
<VirtualHost localhost:8082>
ServerName localhost:8082
DocumentRoot "D:/wamp/www/project1/"
Alias /index.html D:/wamp/www/project1/index.php
</VirtualHost>
答案 0 :(得分:3)
我认为这是一个有点老问题,但我的WAMP仍无法启用vhost。 主机:
<code>
127.0.0.1 localhost
127.0.0.1 sweetdreams.localhost
127.0.0.1 sweetdreams.com
</code>
的httpd.conf:
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "D:/wamp/bin/php/php5.3.4/php5apache2_2.dll"
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Include "D:/wamp/alias/*"
VirtualDocumentRoot "D:/wamp/www/%0"
htppd-vhosts.conf:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName localhost
DocumentRoot "d:/wamp/www" #this is default wamp root for websites,
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName www.sweetdreams.com
ServerAlias www.sweetdreams.com sweetdreams.com #your virtual domain name
DocumentRoot "d:/wamp/www/sweetdreams" #location of your site, no extenison needed.
<Directory "d:/wamp/www/sweetdreams"> #again location of your website
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
当我启用vhost模块并添加vhost conf时,我的WAMP图标保持橙色。
答案 1 :(得分:2)
我不明白为什么你试图将差异端口指向差异项目......
你可以在httpd-vhosts.conf中写这样的东西:
<VirtualHost 127.0.0.1>
DocumentRoot "D:/wamp/www/project/"
# ServerName project[1 ... n].local or domain.name.com
ServerName project1.local
</VirtualHost>
然后你必须从C:\ Windows \ System32 \ drivers \ etc编辑你的主机文件,以便将你的IP与你的本地域相匹配
重启apache,这就是
有效网址应如下所示:http://project1.local - 您将在哪里使用project1 forlder; 为了拥有多个项目,您可以设置所需的VistualHosts指令 欢呼声,
答案 2 :(得分:1)
我遇到了同样的问题,当我在两个locatins中都有端口时,服务器将无法运行。它会留在橙色。尝试删除NameVirtualHost
中的端口,使其如下所示:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1:80>
ServerName localhost
DocumentRoot "d:/wamp/www"
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerName www.sweetdreams.com
ServerAlias www.sweetdreams.com *.sweetdreams.com
DocumentRoot "d:/wamp/www/sweetdreams"
</VirtualHost>