Virtual host does not work with WAMP server

I have a WAMP server installed, it works fine. Then I tried a virtual host with it, it does not work.

In the httpd.conf file, I added these lines

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

And at 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
source share
3 answers

I see this a little old question, but my WAMP does not 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> 

The My WAMP icon stays orange when I turn on the vhost module and add vhost conf.

+3
source

I do not understand why you are trying to specify diff ports for diff projects ...

you can write something like this in 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> 

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

restart apache and that's it

a valid url should look like this: http: //project1.local - where you will have forlder project1; to have multiple projects, you can set as many VistualHosts directives that you need greetings,

+2
source

I ran into the same problem. When I have ports in both locales, the server will not work. He would have stayed with the Orange. Try removing the port in NameVirtualHost so that it looks 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> 
+1
source

Source: https://habr.com/ru/post/1203677/


All Articles