virtual host is not working with WAMP server [closed]

烈酒焚心 提交于 2019-12-11 16:44:08

问题


i have setup WAMP server , it is working fine Then i tried virtual host with it , it doesn't work

In the httpd.conf file i added these lines

Listen 8081
Listen 8082
Include conf/extra/httpd-vhosts.conf

And in the 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>

回答1:


I see it's a bit old question but still my WAMP doesn't work with vhost enabled. hosts:

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

My WAMP icon stays orange when I enable vhost module and add vhost conf.




回答2:


i dont understand why you try to point diff ports to diff projects ...

you can write in httpd-vhosts.conf something like this:

<VirtualHost 127.0.0.1>
    DocumentRoot "D:/wamp/www/project/"
    # ServerName project[1 ... n].local or domain.name.com 
    ServerName project1.local
</VirtualHost>

then you have to edit your hosts file from C:\Windows\System32\drivers\etc in order to match your IP to your local domain

restart apache and that's all

the valid url should be like this: http://project1.local - where you will hve the project1 forlder; in order to have multiple projects you can set as many VistualHosts directives you need cheers,




回答3:


I was running in to the same issue, When i have the ports in both locatins the server would not run. It would stay at Orange. Try removing the port in the NameVirtualHost so it would look like this:

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>


来源:https://stackoverflow.com/questions/4624988/virtual-host-is-not-working-with-wamp-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!