12

I tried enabling Virtual Host on my WAMP installation, but WAMP server will not run if I enable http-vhosts.conf, and the icon remains orange.

Here is my hosts file:

127.0.0.1       localhost
127.0.0.1       test.localhost

My httpd.conf:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

and my httpd-vhosts.conf:

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

It works fine if I add the VirtualHosts to my httpd.conf, but I noticed that the Apache server will not run if I comment out "Include conf/extra/httpd-vhosts.conf". What is causing this issue?

Thanks,

seemvision
  • 242
  • 1
  • 2
  • 12
  • 10
    go to your apache folder, run httpd.exe from command line, it will show the error. – scalopus Apr 20 '12 at 14:10
  • You may get better help on http://serverfault.com/ - This site is more geared toward the actual programming end of things. – Gary Apr 20 '12 at 14:11
  • Why are you commenting out the "Include conf/extra/httpd-vhosts.conf", don't you want to uncomment it? Also, check you error log. –  Jul 07 '12 at 03:49

3 Answers3

20

To determine the exact line on which the error is occurring, take the following steps:

  1. Go to start menu
  2. type "cmd"
  3. press enter
  4. paste the following C:\wamp\bin\apache\apache2.2.22\bin\httpd.exe

Note: You may need to tweak the apache2.2.22 portion of the path according your local version of Apache.

pim
  • 12,019
  • 6
  • 66
  • 69
11

OK I feel this my duty to put this...

I too went on a rampage of checking forms and doing things like

Listen *:80 & NameVirtualHost *:80 but found that this was not necessary, the default settings were fine for me.

the problem started when I tried to put in my vhost declaration

<VirtualHost 127.0.0.1>
    DocumentRoot 'c:\wamp\www\media_weber_edu\public'
    ServerName media.weber.dev
    <Directory 'c:\wamp\www\media_weber_edu\public'>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
    <\Directory>
</VirtualHost>

here lied the problem

<\Directory> vs </Directory>

A huge help to finding this was running C:\wamp\bin\apache\apache2.2.22\bin\httpd.exe

this gave me an error like this

httpd.exe: Syntax error on line 469 of C:/wamp/bin/apache/apache2.2.22/conf/httpd.conf: Syntax error on line 42 of C:/wamp/bin/apache/apache2.2.22/conf/extra/httpd-vhosts.conf: Expected </\\Directory> but saw </VirtualHost>

So this may not be the exact problem but I hope this will help those in the future. So take a deep breath... glue the hair back on your head... its going to be ok :)

Dustin Woodard
  • 929
  • 9
  • 10
0

You just need to change it like as this: everything will be OK.

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

If somebody has error of Directory, he may need to modify it like below:

<VirtualHost 127.0.0.1>
#    DocumentRoot 'c:\wamp\www\media_weber_edu\public'
     ServerName media.weber.dev
#    <Directory 'c:\wamp\www\media_weber_edu\public'>
#        Options Indexes FollowSymLinks MultiViews
#       AllowOverride all
#    <\Directory>
</VirtualHost>

notes: Apache does not allow multiple <Directory> arguments!

multiple <Directory> arguments error screenshot:

xgqfrms
  • 10,077
  • 1
  • 69
  • 68