How to get the Apache virtual hosts working

apache-2.2domain-name-systemvirtualhostwindows-vista

I'm trying to set up virtual hosts for local development and can't seem to get it working.

I have this in my httpd.conf:

NameVirtualHost *

<VirtualHost *>
 ServerName localhost
 DocumentRoot C:/Users/Elliot/dev/UniServer/www
</VirtualHost>

<VirtualHost *>
 ServerName drupal.dev
 DocumentRoot C:/Users/Elliot/dev/UniServer/www/drupal.dev/httpdocs
</VirtualHost>

and this in C:\Windows\System32\drivers\etc\hosts:

127.0.0.1       localhost
127.0.0.1       drupal.dev

http://localhost resolves OK, http://drupal.dev/ does not.

Any ideas welcomed…


Edit: I'm pretty sure that my hosts file is the underlying problem and that any edits are being ignored.

Oddly, I can edit, save and delete it without elevated permissions, which should not be the case on Windows >= Vista.

Am working through 'What can cause a DNS lookup to ignore a hosts file entry?', 'HOSTS file being ignored' and 'Problem with the hosts file in Windows XP (as a new user I can't post links).


Edit: in my case, stopping the DNS Client service resolved the issue….


Edit: …but only very briefly.

Best Answer

Do a ping of drupal.dev and make sure its resolving to your machine. Also, try setting the documentRoot to the same as the one above (C:/Users/Elliot/dev/UniServer/www/) just in case it's a premissions issue.