Ok, I normally use WAMP Server to setup my own local server machine. I use it on my WordPress site, Drupal, and now with Magento 1.7. Basically, I place everything under one common roof “D:\wamp\www” folder. At first, it’s kinda easy to remember which folder name I put my wordpress site and my drupal site but as my number of sites grew, especially when I install Magento 1.7, it’s now very difficult to remember specific folder to type in your browser.

Let us say I want to open my site for wordpress, so I need to key in my browser “http://localhost/wordpress/” or for drupal “http://localhost/drupal” and for Magento 1.7 “http://localhost/magento/” but what if you have a lot of sites for each CMS? I bet you’ll be mixed up from time to time.

So, how do we solve this problem? We will create a virtual host using the Wamp Server. For me, this is the fastest and easiest method to create a virtual host. Let’s start..

  1. Edit the httpd-vhosts.conf of your wamp. To do this, Open RUN (shortcut key Win+R ) and copy-paste the path below and press OK. Take note that my wamp was installed in drive D:. (Change to C:\wamp… If you install your wamp under drive C:  )
    [text] D:\wamp\bin\apache\Apache2.2.21\conf\extra\httpd-vhosts.conf [/text]httpd-vhosts.conf
  2. Copy-paste the Text below and save.NameVirtualHost *:80<VirtualHost *:80>
    ServerName localhost.com
    ServerAlias www.localhost.com
    DocumentRoot “d:\wamp\www”
    ErrorLog “logs\errors.log”
    <directory “d:\wamp\www”>
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from all
    </directory>
    </VirtualHost><VirtualHost *:80>
    ServerName localhost.com
    ServerAlias *.localhost.com
    VirtualDocumentRoot d:\wamp\www\%1
    ErrorLog “logs\errors.log”
    <directory “d:\wamp\www\%1”>
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from all
    </directory>
    </VirtualHost>

     

  3. Enable the vhost_alias_module on your wamp server.  Right click Wamp Tray -> Apache -> Apache Modules -> right click vhost_alias_module (Restart WAMP All Services after you’ve done this)
  4. Edit your windows hosts file. To do this, Open RUN (shortcut key Win+R ) and copy-paste the path below and press OK. It will open hosts file automatically using notepad.
    [text] notepad C:\windows\system32\drivers\etc\hosts [/text]
  5. You may now add all the folders under your “D:\wamp\www”. In my case, I added WordPress, Drupal & Magento as shown below.hosts Magento 1.7 Wamp server 2.2
  6. To open any local site I have, I’ll just input magento.localhost.com or wordpress.localhost.com on my browser.Note: You may now customize your own folder (whatever name you prefer for you to remember easily). Ex. rename the folder “Magento” folder to “m”. And add this line ” 127.0.0.1       m.localhost.com ” to your hostsfile.Now, every time you will open your Magento Site, you’ll just type “m.localhost.com” in any browser.. 😉

This is how I install virtual host on my wamp server 2.2x for Magento 1.7. Let me know if you have any questions. Enjoy 😉