Wednesday, April 29, 2009

Setting up multiple virtual hosts on wamp in XP

This was something which needed desparately. Finally, I learnt how to setup multiple virtual hosts on WAMP. Here you go.

When you install WAMP, it gets installed as a package and the webroot pointing to
      C:\wamp\www.

1. Create a project directory, for example 
      C:/wamp/www/MyProject

2. Add the new host name in Windows hosts file located at
     C:\WINDOWS\System32\drivers\etc\hosts

     127.0.01 localhost
127.0.0.1 myproject

3. Edit the httpd.conf file to add path to virtualhosts definitions. In WAMP, by default this is line is commented. We have to uncomment the line and link it to correct file path.
       # Virtual hosts
         Include conf/extra/httpd-vhosts.conf

4. In httpd-vhosts, specify the mapping from MyProject folder to the new hostname.
       NameVirtualHost *:80

# this is the default mapping to http://localhost/ 
     <VirtualHost *:80>
         DocumentRoot C:\wamp\www 
         ServerName localhost 
     <\VirtualHost>

# this is the default mapping to http://myproject/ 
  &lt;VirtualHost *:80>
       DocumentRoot C:\wamp\www\MyProject\html 
      ServerName myproject
      <Directory "C:\wamp\www\MyProject>
           Options Indexes FollowSymLinks Includes 
          AllowOverride All 
          Order deny,allow 
           Deny from all
           Allow from 127.0.0.1 
             DirectoryIndex index.php 
         <\Directory>
<\VirtualHost>


5. Restart apache.

Good to go.

Hav fun :)

No comments: