Virtual Hosts - what am I missing?

I know it’s essentially pretty straight forward setting up virtual hosts, but I must be missing something, because for the last 5 hours, I cannot for the life of me get it working.

Here’s what I’ve done:

  1. Editted httpd.conf by uncommenting the httpd-vhosts.conf line

  2. Created two <virtual host> containers in the httpd-vhosts.conf file, like so:

<VirtualHost *:80>
DocumentRoot “C:/wamp/www”
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “C:/wamp/www/testSite”
ServerName testSite.local
</VirtualHost>

  1. Edited the hosts.txt by adding the following line: 127.0.0.1 testSite.local

It all seems so straight forward, except that it doesn’t work! It says server not found when I go to testSite.local. Localhost works fine and the WampServer is green (though it says offline).

Please can somebody point me in the right direction! I’ve been reading the same suggestions all day and they don’t seem to apply to my particular issue.

Thank you!

-Victor

Hi vkloss. Welcome to the forums. :slight_smile:

This is not my area, but I did find this link helpful a while back, so am posting in case it helps you: http://sawmac.com/xampp/virtualhosts/

Hi vkloss,

I’ve only ever used XAMPP and MAMP, but I’ll assume WampServer is very similar. A few things I see that might need tweaking:

  1. In your httpd-vhosts.conf, you shouldn’t even need this part:
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
</VirtualHost>

http://localhost should just work without that part. For your testSite, try this instead in httpd-vhosts.conf:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot “C:/wamp/www/testSite”
ServerName testsite.local
ServerAlias www.testsite.local

&lt;Directory "C:/wamp/www/testSite"&gt;
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
&lt;/Directory&gt;

</VirtualHost>

  1. I’m not sure what version of Windows you’re running, but your hosts file shouldn’t have the .txt file extension. It should just be hosts. In Vista it’s usually located at Windows\System32\drivers\etc. To edit it you have to run your text editor as an Administrator. You will probably also have to modify the Properties of the hosts file so that “Read-only” isn’t checked off. After you change your hosts file, make sure to checkmark “Read-only” back.

vk,

The thing that jumped out of your post at me was the “hosts.txt” file. hosts is an extensionless file located in the Windows (i.e., protected) directory so, if you’re using any Windows more advanced than XP, you’ll need to run your text editor (NOT Notepad) as the administrator so you can save the file (it will not save if not done as the administrator). With that, I think you’re set (leave the virtual host definitions in the extras/httpd-vhosts.conf file, though, IMHO).

Regards,

DK