Accessing WAMP from a Virtual Machine

With all modern browsers now embracing automatic upgrades, it won’t be much longer that you have to worry about sites being compatible with old versions of Internet Explorer. However, a significant portion of site owners will continue to support old IE versions. Businesses make their browser support decisions based on the customers they serve – all money is green. In my estimate, old versions of Internet Explorer (particularly IE9) will continue to require support for [at least] the next 3 years.

Virtual Machines are a great way to setup browser testing environments. While I am aware of tools like BrowserStack, nothing matches the experience of running your site in the target browser on your machine. In the case of setting up testing environments for Internet Explorer, Microsoft has done the developer a community a great service with its modern.IE project.

In this post, I’ll configure a virtual machine running IE8 (provided by the modern.IE project) to connect to WAMP – which runs on my physical machine. This will allow me to develop on my local machine while being able to test in the actual browser in a virtualized environment on the same machine.

Before getting started, it’s worth your time to review an excellent reference published by the Tuscon Computer Society about virtual networking with Windows Virtual PC.

Configuring The Virtual Machine

Your browser testing environment

  1. Add a new entry in the hosts file on the virtual machine that points to the vhost on the machine running WAMP. The hosts file is located at C:\Windows\System32\drivers\etc\hosts.

    Screenshot of the Windows hosts file from a virtual machine
    Windows Hosts File

    Your physical machine running WAMP should be assigned a static IP to avoid IP address changes via DHCP.

  2. Update the network settings on your Virtual PC instance so that it uses the network adapter on your physical machine. Doing this puts the virtual machine’s network adapter in bridged mode, making the virtual machine act as if it were a physical machine on your network.

    Screenshot of the tools dropdown on Microsoft Virtual PC
    Access Virtual PC Settings

    Screenshot of the networking Settings on Microsoft Virtual PC
    Virtual PC Networking Settings

    Screenshot of the network adapter Settings on Microsoft Virtual PC
    Virtual PC Network Adapter Settings
  3. Assign a static IP address to your virtual machine.

Configuring The Physical Machine

Your WAMP server host

  1. As mentioned in the alert message above, ensure that your physical machine running WAMP has been assigned a static IP address.
  2. Open the WAMP httpd-vhosts.conf configuration file located in C:\wamp\bin\apache\apache#.#.##\conf\extra and add an exception for your virtual machine’s IP address before the closing </directory> line.

    Screenshot of the vhost configuration for statesupply.local
    Virtual Host Exception for VM

    If you are not using virtual hosts in WAMP, you’ll want to edit the httpd.conf configuration file instead, located up one directory in C:\wamp\bin\apache\apache#.#.##\conf.

  3. Restart all services in WAMP and enjoy dealing with your old Internet Explorer issues.

    Screenshot of the WAMP menu option to restart all services
    Restart All Services

Leave a Reply

Your email address will not be published. Required fields are marked *