VirtualHosts doesn't work on Win7
Posted by: mogop (---.comnet.bg)
Date: June 22, 2012 05:01PM

I'm using WAMP 2.1 - apache 2.2.17, php 5.3.4, mysql 5.1.53 on Windows 7 x64
I can't manage to run VirtualHosts. Bellow are my conf and when I use them WAMP doesn't start (my icon stay orange)


hosts:
127.0.0.1 localhost
127.0.0.1 sweetdreams.localhost
127.0.0.1 sweetdreams.com


httpd.conf:
LoadModule vhost_alias_module modules/mod_vhost_alias.so

Include conf/extra/httpd-vhosts.conf

Include "D:/wamp/alias/*"

VirtualDocumentRoot "D:/wamp/www/%0"

httpd-vhosts.conf:

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin root@localhost
ServerName localhost
DocumentRoot "d:/wamp/www"
ErrorLog "d:/wamp/logs/localhost-error.log"
CustomLog "d:/wamp/logs/localhost-access.log" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin root@sweetdreams.com
ServerName sweetdreams.com
ServerAlias www.sweetdreams.com
ErrorLog "d:/wamp/www/sweetdreams/logs/sweetdreams-error.log"
CustomLog "d:/wamp/www/sweetdreams/logs/sweetdreams-access.log" common
DocumentRoot "d:/wamp/www/sweetdreams"

<Directory "d:/wamp/www/sweetdreams">
Options Indexes FollowSymlinks
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>

I try diffrent approaches - NameVirtualHost,VirtualHost 127.0.0.1 , 127.0.0.1:80, *:80, 80



Edited 2 time(s). Last edit at 06/22/2012 06:41PM by mogop.

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: stevenmartin99 (Moderator)
Date: June 22, 2012 05:13PM

Wamp has moved to using

Require local now

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: mogop (---.comnet.bg)
Date: June 22, 2012 06:42PM

Sorry, What ?
"Require local now" ?

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: mogop (---.comnet.bg)
Date: June 23, 2012 07:54PM

anyone ?

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: HarryWamp (---.alcatel.fr)
Date: June 27, 2012 11:14PM

see mod_authz_hosts [httpd.apache.org]

try removing next 2 lines( or put # in front of the line)

Order Allow,Deny
Allow from all

and insert
Require all granted


- Harry

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: mogop (---.comnet.bg)
Date: June 30, 2012 01:07PM

where to find these lines? Which file -httpd.conf or httpd-vhosts.conf.
I mean there are many <Directory> which I should change to "Require all granted".

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: jagi (---.elpos.net)
Date: July 01, 2012 02:40PM

Works for me WAMP2.1 and win7 64.

Changed:
1. win7 hosts file
2. httpd.conf


In httpd.conf like:

NameVirtualHost 127.0.0.1:80


<VirtualHost artcode.eu.localhost:80>
DocumentRoot "D:/codeArt/artcode.eu/public_html"
ServerName artcode.eu.localhost:80
</VirtualHost>


My problem was win7 hosts file + restart + clear cache ... now works OK



Edited 1 time(s). Last edit at 07/01/2012 05:40PM by jagi.

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: mogop (---.comnet.bg)
Date: July 02, 2012 01:44PM

I tried this with httpd-vhosts.conf but still doesn't work - can't start WAMPSERVER

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: jagi (---.elpos.net)
Date: July 02, 2012 02:01PM

Try directry in httpd.conf.

Where You have this line? :

NameVirtualHost 127.0.0.1:80



Clear Apache error log. Restart wamp. Send me new log.

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: mogop (---.comnet.bg)
Date: July 02, 2012 03:32PM

when I deleted the all log files from /wamp/logs/ and /wamp/bin/apache/apache2.2.17/logs they can't be created new ones, so I created them by manually but still they are empty except mysql.log.
I put those lines directly in httpd.conf


Include "D:/wamp/alias/*"


VirtualDocumentRoot "D:/wamp/www/%0"

NameVirtualHost 127.0.0.1:80


<VirtualHost localhost:80>
ServerAdmin root@localhost
ServerName localhost
DocumentRoot "d:/wamp/www"
ErrorLog "d:/wamp/logs/localhost-error.log"
CustomLog "d:/wamp/logs/localhost-access.log" common
</VirtualHost>

<VirtualHost sweetdreams.com.localhost:80>
ServerAdmin root@sweetdreams.com
ServerName sweetdreams.com.localhost
ServerAlias www.sweetdreams.com.localhost

DocumentRoot "d:/wamp/www/sweetdreams"

<Directory "d:/wamp/www/sweetdreams">
Options Indexes FollowSymlinks
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>



and disable " Include httpd-vhosst.conf" and modules/mod_vhost_alias.so still can't start apache. So I try from task manager to start the wampapache service but it doesn't start.
from the command line I navigate to D:\wamp\bin\apache\Apache2.2.17\bin and try httpd.exe which gives me some errors:
Syntax error on line 192 of D:/wamp/bin/apache/Apache2.2.17/conf/httpd.conf:
Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration
even when I comment out these lines I receive another error for another line:
Syntax error on line 260 of D:/wamp/bin/apache/Apache2.2.17/conf/httpd.conf:
Invalid command 'Deny', perhaps misspelled or defined by a module not included in the server configuration

Now this is how my httpd.conf looks like - [pastebin.com]

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: jagi (---.elpos.net)
Date: July 02, 2012 04:29PM

1. You must start Apache - try with oryginal httpd.conf

on success with Apache on localhost
go to step 2

2. add ONLY this line on top of httpd.conf
NameVirtualHost 127.0.0.1:80

and ONLY this simple declaration

<VirtualHost sweetdreams.com.localhost:80>
DocumentRoot "d:/wamp/www/sweetdreams"
ServerName sweetdreams.com.localhost:80
</VirtualHost>

P.S any other changes make step-by-step :
1 change - restart all services - on success make next change - restart ...

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: RiggsFolly (---.as13285.net)
Date: July 02, 2012 05:25PM

mogop,

1. Remove this line its for Dynamically Configured Mass Virtual Hosting and you dont want to do that.
..... remove
..... VirtualDocumentRoot "D:/wamp/www/%0"

2. RE Comment out this line
.... comment out with a #
.... LoadModule vhost_alias_module modules/mod_vhost_alias.so
You do not need Dynamically Configured Mass Virtual Hosting
you want Name-based Virtual Hosting


All you need to change in the httpd.conf file is to UN-comment this line which you already did.
Include conf/extra/httpd-vhosts.conf

The included file should look like this:


#
# Use name-based virtual hosting.
#
NameVirtualHost *:80


## must be first so the the wamp homepage loads
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
</VirtualHost>

# Place your source folders outside the wamp folder
# so if you have to upgrade or re-install you dont loose your source code
<VirtualHost *:80>
DocumentRoot "C:/websrc/site1"
ServerName site1.localhost
ServerAlias site1.localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/websrc/site2"
ServerName site2.localhost
ServerAlias site2.localhost
</VirtualHost>

.... You can add as many sites as you like

If you have something like a DYNDNS address registered and pointing to your router and the router has got port 80 port forwarded to the PC running WAMP you can also allow access from the outside world.
So assuming you have registered a site with the name site2.dyndns.org
You can also allow this

<VirtualHost *:80>
DocumentRoot "C:/websrc/livesite"
ServerName site2.dyndns.org
ServerAlias site2.dyndns.org
</VirtualHost>


Note you would have to run Wamp manager "Put Online" to allow access from the outside world.
Put Offline ( the state wamp is installed in ) set httpd.conf to only allow access from 127.0.0.1
changing it to ONLINE allows access from ALL.
And thats all Put Online does.

Options: ReplyQuote
Re: VirtualHosts doesn't work on Win7
Posted by: mogop (---.comnet.bg)
Date: July 02, 2012 07:35PM

Thank for the help guys! thanks to jagi httpd.conf I saw that I have a <directory> tag that should be there

<Directory "D:/wamp/www/sweetdreams"/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Deny from all
</Directory>
with that tag I can't start the server.
I change my httpd-vhosts.conf also like you said so now Wampserver works with VirtualHosts.

Thank You

Options: ReplyQuote


Sorry, only registered users may post in this forum.