Categories
PHP

HOWTO: Use VirtualBox to setup an Internet Explorer testing machine

There are a lot of cases where having one computer just isn’t enough. If you’re a web developer or webmaster, you’ll want to view your website in more than one browser. If you’re a PHP programmer, you may be itching to check out the new 5.3 release and test your web applications on it. Using virtualization, you can set up self-contained instances of any Operating System configured to your heart’s content on your computer.

There are a lot of virtualization environments out there. VirtualBox is an Open Source virtualization solution from Sun. I particularly like that it runs not only in Linux, but also on Mac OS X and windows. In this post I’ll show you how to set up VirtualBox with disk images supplied by Microsoft for testing Internet Explorer compatibility in OS X. The instructions are based on this article for setting up VirtualBox in Ubuntu.

Download supporting files and utilities

To get each environment setup, you’ll need a few files and tools installed to get everything working.

1. Install RAR

Download the RAR Utility for Mac OS X, as of this writing its labeled RAR 3.90 beta 3 for Mac OS X. The download file is a .tar.gz file. In OS X terminal you can use tar -xvzf rarosx-3.9.b3.tar.gz to extract the files. Next, you’ll want to copy the extracted files to /usr/local/bin/ or anywhere else that is in your $PATH.

2. Install Burn

We’ll need to create an .ISO file for the networking drivers expected by the Windows images. Burn 2.3u is a free and straightforward tool for burning disks or creating disk images. Simply download it and drag it into your Applications folder.

3. Download PCNET Drivers and create ISO file

Since we’ll want our virtual Windows machines to get on the Internet, you’ll need to download the correct drivers from AMD. Download the ZIP file labeled NDIS5 Driver dated August 2004 and unzip them somewhere. Launch the Burn application and drag the PCNET files from where you extracted them into the Burn app. To create the ISO file, select "Save Image" from the File menu. Save the ISO file somewhere where you’ll remember it, as you’ll need it later.

4. Install VirtualBox

Head on over to the VirtualBox downloads page and download the binary for OS X hosts. Double click on the disk image (dmg) file to mount it, and double click on VirtualBox.mpkg to run the installer. Once installed, VirtalBox will be in your Applications folder.

Setup Windows XP Images in VirtualBox

If you’ve made it this far, you should have VirtualBox installed and all the tools for setting up a Windows XP or Vista image. Repeat this part for each XP Image you want to install, MS provides a number of images combining XP/VISTA with IE6/IE7/or IE8.

5. Download a Windows Image.

Select an image to download from the Internet Explorer Application Compatibility VPC Image page. These images are fairly large, the smalles is 465MB.

6. Extract the .vhd file from the image

Microsoft’s VPC images are mean to be used with their own VirtualPC technology. Luckily, VirtualBox can read VirtualPC’s .VHD files. Use rar to extract the files from the .exe or .rar file you download, as follows.

unrar e IE6-XPSP3.exe

7. Create a new VirtualBox machine

Now that you have the disk image, launch VirtualBox and create a new machine. Make sure you select Windows XP as the Guest OS, and give it enough memory to run well. This depends a lot on how much memory your Host OS has, you can get away with 256MB but I like to give them 512MB if possible. When it asks you

When the new machine wizard prompts you for the hard disk image to use, select the .vhd file extracted in step 6.

8. Launch the new machine and install Guest Additions and network drivers

If you have your new machine setup, click on the green start arrow to boot it. You should see the Windows boot sequence and eventually you’ll get to the Windows desktop. You’ll get prompted a hundred times to install new hardware and connect to Windows update, but just hit cancel until Windows stops trying to be helpful.

First, install the Guest Additions which provide a more seamless transition between Host and Guest OS by clicking on "Install Guest Additions" in the Devices menu

Next, mount the ISO image created in step 3 as a CD. Click on Devices, then Mount CD/DVD-ROM and CD/DVD-ROM Image. Selct the ISO image and then you should see its contents in the virtual CD-ROM drive.

Finally update the network drivers to get the network card working. Select My Computer, click on View System Information, Go to System > Devices, Click on Hardware tab, then Device Manager button. Select ethernet device under Network Adapters and then right click, select Update Drivers, say no to Windows Update, then click Next. Windows should find and install drivers from the CD.

Gotchas and where to go from here.

At this point you should have a working virtual machine with network access. You can repeat steps 5-8 for other Windows images to have one or more environment for testing each version of Internet Explorer. If you do install other Windows images, be aware that the supplied MS Images may all have the same disk UUID, in which case VirtualBox refuses to add them to the Media list. Use VBoxManage to clone the disk image and generate a new UUID. You’ll have to remove the conflicting disk from the list first, and to remove it the virtual machine must be powered off. From the command line, the following will clone a drive:

VBoxManage clonehd XP SP3 with IE7 2009-Apr.vhd IE7_XPSP3.vhd XP_SP3_IE7.vhd

If you’re setting up IE testing environments, I highly recommend that you install the MS IE Developer toolbar too. It’s very helpful in diagnosing Internet Explorer behaviors.

Now that you have VirtualBox running, you’re not limited to Windows images. You can also setup your Linux distribution of choice in a VirtualBox machine. You could setup a copy of your LAMP environment for testing and expirementation.