Crafting Your Windows / IE Test Environment on OSX 10.6

16 Comments

Mar 8, 2012

Tutorials
John Manning
Crafting Your Windows / IE Test Environment on OSX 10.6

Hello, world – this is my first post! I’ve learned a bunch since joining the Studiobanks team three months ago. Lots of that learning has been dedicated to becoming accustomed to a new workplace (workflows, project history etc), but at least one universal pearl of wisdom comes to mind that I think would be helpful to lots of folks – testing Internet Explorer 6, 7, 8, and 9!

Since we’re all Mac here at the office, I’ve become reasonably familiar with the process of setting up multiple virtual machines to provide a rock-solid (and free) testing environment on my local computer. I’ve employed other techniques over the years (IETester, online screenshot services), but nothing comes close to having the actual browsers loaded in their own sandboxed environment. We’ll achieve this by creating four separate virtual machines in VirtualBox.

Additionally, we’ll look at getting MAMP installed and configured so you can test your local sites inside the VMs without having to constantly upload to an external server. I love that part.

Goals

By the end of this guide, you should have the following items working:

  • MAMP – used to run Apache, MySQL, and PHP locally
  • VirtualBox – used to create the virtual machines that will run Windows / IE
  • A separate VM for each version of IE (6, 7, 8, 9)
  • A simple html file that you can access locally on your Mac and in all four VMs

Credit

I used three sites heavily when setting up my environment the first time. This guide is going to lean on them a lot. Credit is due to the following:

  • https://github.com/xdissent/ievms
  • http://jeffrey-parker.com/blog/dev/how-to-use-ie6-ie7-ie8-and-ie9-and-other-windows-apps-on-osx-lion-using-virtualbox-for-free-legally
  • http://osxdaily.com/2011/09/04/internet-explorer-for-mac-ie7-ie8-ie-9-free/

Setup

This guide is written from the perspective of OSX 10.6. Things may be a smidge different for other versions, but I expect this will give you a great head start. Let’s get to it!

The first piece of upkeep is to set up our folder structure. I like to keep all of my local websites organized in a single “Sites” folder in my User folder. I keep a shortcut to the Sites folder in my Finder sidebar so it’s always just a click away. It’s certainly possible to use another setup, but this guide is going to refer to Sites.

Inside the Sites folder, create a subfolder called “greatwebsite.local” This is going to hold all of your site’s files. Inside greatwebsite.local, create an index.php (or .html) file and put some kind of message in it (“Hello world” etc). This is just going to help us see that things are working down the road.

You should end up with:

/Users/USERNAME/Sites/greatwebsite.local/index.php

Apps

We’ll be using these items. Hold off on downloading them all at once. I’ll get to them individually:

IEVMS

Though we won’t get to configuring this piece until a little later, this is really the meat-and-potatoes of what we’re doing. GitHub user Greg Thornton has made this process infinitely simpler by providing readily available packages for each virtual machine you need to create. Not only do these packages provide a stable Windows install with the browsers pre-installed, but he’s discovered that by using VirtualBox’s Snapshot feature that we’re able to run these installs forever, without having to worry about Windows registration or activation. Sound a little shady? Not to worry. These packages are based on virtual machines that Microsoft originally released for this very reason. The Snapshot feature simply allows us to return to a “just installed” state if the VM ever tries to force you to activate the OS. Huzzah!

Mr. Thornton has provided four separate packages – one per browser for IE 6, 7, 8 and 9. It’s possible to download all of these images at once, but I highly recommend grabbing them one at a time. They’re pretty large and you don’t want a download to fail in the middle and have to start over again.

IEVM on GitHub

So, go to the GitHub project page and see the Installation section. You’ll want to copy the terminal command under item 2 for “Install specific IE versions.” Fire up Terminal, jog over to your User folder, and paste in the command. Then, edit the command to install ONLY IE6 (repeat for other versions). Your command should end up being:

curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="6" bash

Execute!

You should see lots of text and a (probably slow) progress ticker that shows the package being downloaded. This is going to take a while, so we’ll do some other setup in the meantime.

MAMP

MAMP is going to run Apache, MySQL, and PHP for you on your own machine. If you’re already using MAMP, be sure to check your configuration and keep any differences in mind for later. This guide is going to make some customizations to the default preferences.

You can get MAMP here.

MAMP preferences

Once you’ve got it installed in your Applications folder, go ahead and launch it. Once it’s running, click the Preferences button and make these changes:

  1. On the Ports tab, change the default port from 8888 to 80.
  2. Next, click the Apache tab. Use the “Select” button to navigate to your Sites folder (or equivalent).

Now we need to edit a few Apache configuration files. You’ll want to open them in a text editor that shows line numbers. I prefer TextWrangler, but anything that shows line numbers will do. Take a deep breath:

Applications/MAMP/conf/apache/httpd.conf

Apache httpd.conf

  1. Line 48: Change “Listen 8888" to “Listen 80"
  2. Line 179: Change “ServerName localhost:8888" to “ServerName localhost:80″
  3. Line 199: Change “AllowOverride None” to “AllowOverride All”
  4. Line 247: Add “index.htm” if you want to use that extension for your index file (optional).
  5. Line 346: Change “AllowOverride None” to “AllowOverride All”
  6. Line 355: Change “AllowOverride None” to “AllowOverride All”
  7. Line 364: Change “AllowOverride None” to “AllowOverride All”
  8. Line 373: Change “AllowOverride None” to “AllowOverride All”
  9. Line 403: Change “AllowOverride None” to “AllowOverride All”
  10. Line 525: Uncomment this line (delete “#” at the beginning).
  11. Save your file (Control + S since you’re in Windows) and close it.

Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

Apache httpd-vhost.conf

  1. Copy the bottom-most block that begins with “<VirtualHost 1. :80>” and ends with “</VirtualHost>” Paste that block at the bottom of the file.
  2. Delete the lines for “ServerAdmin,” “ServerAlias,” “ErrorLog,” and “CustomLog.” You can use these lines for advanced configurations, but we don’t need them.
  3. You should be left with “DocumentRoot” and “ServerName.”
  4. On the DocumentRoot line, change “dummy-host2.example.com” to “greatwebsite.local”
  5. On the ServerName line, change “dummy-host2.example.com” to “greatwebsite.local”
  6. Save your file (Control + S) and close it.

That’s it for MAMP. Go ahead and quit the application to get it out of the way.

GasMask

GasMask is a little application that makes it super easy to edit your machine’s hosts file, which is responsible for telling your browser what IP address to associate with a domain name. In a local test environment, you need a unique entry for each site you want to test. Our testing URL is going to be “greatwebsite.local.” It’s a good idea to develop a convention for your url extensions to keep things tidy. You don’t have to use “.local” – whatever you choose, just make it consistent.

Once GasMask is downloaded and installed, go ahead and launch it. You should see a line that says “127.0.0.1 localhost.”

GasMask setup

  1. Copy that line and paste it at the bottom of the document, underneath anything else you see.
  2. Change “localhost” to “greatwebsite.local” (the url we’re going to use to test our setup).
  3. Be sure to SAVE your hosts file, then quit GasMask.

VirtualBox

VirtualBox is a free application developed by Oracle that allows you to create multiple instances of other operating systems. Each of these instances is called a virtual machine. We’re going to end up with four virtual machines – one per browser that we need to test.

By this point, your IE6 package should be finished downloading. You’ll know it’s done if you see “Done” and your bash prompt in the Terminal window. If it’s not, go get a beverage, throw some darts, or maybe do a little vacuuming.

This download will create a new folder called “VirtualBox VMs” in your user folder. There should also be an “IE6″ folder inside of the parent. If everything seems to be finished downloading and you’ve got VirtualBox installed, go ahead and launch it.

VirtualBox - IE6 only

You should see an entry for “IE6″ in the left hand column. This represents the virtual machine that you’re going to use to test IE6. Don’t launch it yet! We need to customize a few things:

VirtualBox Network Settings

  1. Launch System Applications > Network. Make a note of your IP Address (mine is 192.168.1.81) and the name of the active connection in the left column (mine is Ethernet 2).
  2. Back in VirtualBox, select the IE6 VM and click the Settings button.
  3. On Network > Adapter 1, change “Attached to:” to “Bridged Adapter”
  4. Change “Name:” to match the name of the active connection that you saw in System Preferences.
  5. Expand the Advanced section, and change “Adapter Type:” to “Intel PRO/1000 MT Desktop (82540EM).”
  6. Click OK to exit Settings.

Launch IE6 VM

Whew! That’s a lot of reading and customizing. You’re almost there. In VirtualBox with IE6 selected, click “Start.” When was the last time you saw Windows XP boot? It should be doing so now. Use “Password1″ to log in.

If this is the first time you’re launching VirtualBox, you’ll probably see a notification about “hotkeys.” Basically, when you’re working inside the VM, all your mouse and keyboard input is going to be applied to the VM. Use your hotkey (left Command) to escape the VM sandbox and get control of your mouse and keyboard back.

You’re going to be presented with lots of loud warnings about Windows not being activated and new hardware being detected. You shouldn’t care about any of them – other than that you need to dismiss / cancel them as they appear. If you’re asked to restart the system, refuse! So, just hit Cancel or No in the dialogs that appear until you’re left with a an open text file on the desktop. Then, close that text file and we’re ready to proceed.

Full-Screen Viewing

You’ll probably notice that XP is running inside a cramped little window. We can fix that! The package you downloaded from GitHub contains a pre-mounted disk image called “Guest Addons” that will help you run the VM in full screen mode. When you’re ready:

  1. Hit your hotkey (left Command) to get control of your mouse back. Resize the main Mac window that your VM is running in to a better size
  2. Back in the VM, click the Windows Start button
  3. Head to Control Panel > Display > Settings tab
  4. Under “Screen resolution,” move the slider to a reasonable size – whatever your monitor will support. I ended up using 1280 x 1024.
  5. Hit Apply, then confirm the setting when asked.
  6. Close all of the open windows – you should now be running close to full screen.

Network Drivers

IE6 Network Drivers

For IE6 only, you need to install networking drivers to allow the VM to communicate with the Internet and your local computer. The GitHub package helps us out here too. The IE6 VM should already be loaded with “drivers.iso” mounted on its E: drive. To install the drivers:

  1. Choose Start > My Computer
  2. Click “Folders” at the top of the window
  3. Choose “drivers (E:)” from the left column
  4. Double-click “PRO2KXP” to install the drivers

You don’t need to change any of the defaults during the install process. As soon as the install is finished, you can optionally eject the drivers.iso image from the E: drive just to keep things clean – you won’t need it again.

Launch Internet Explorer 6

Now that the network drivers are installed, you should be able to connect to the Internet. Just select Start > Internet Explorer and it should connect to good ol’ msn.com.

Configure Hosts File

Getting IE online is half the battle. The real point of all of this is to be able to test your local website directly in the VM without having to upload files to an external server. To do so, you need to edit the Hosts file. It’s hidden in a deep dark corner of Windows, of course.

C:\Windows\System32\drivers\etc\hosts

Once you’ve located that file, go ahead and right-click on it and choose “Send To > Desktop (create shortcut)”. Find the shortcut on your desktop and open the file. Essentially, we’re performing the same action as when we used GasMask to edit your Mac’s Hosts file. But this time, instead of using 127.0.0.1 to point to greatwebsite.local, you need to use your Mac’s internal IP address. You can find it in System Preferences > Network if you didn’t make a note of it earlier.

IE6 Hosts file

Back in the VM’s hosts file, make a new line at the bottom of the file, enter your Mac’s local IP, and then put in “greatwebsite.local” for the url you’re going to use to test. For subsequent sites, you’d just copy the “greatwebsite.local” line and update the url (to “someothersite.local” or whatever you want it to be called).

SAVE the hosts file (again, Control + S), then head back to IE. Enter “greatwebsite.local” for the url – hopefully you should see your “Hello, world” message.

How to Shut Down / Save Machine State

So now you’re able to test. But what about when you want to close the VM? This is a bit non-intuitive. It’s certainly possible to shut down the VM using the Start menu, but you should definitely avoid doing so. The great power of these GitHub packages is that they provide a way to use the VMs indefinitely. So instead of shutting down, you actually should “Save Machine State” whenever you want to exit a VM. Do do this:

IE6 save machine state

  1. Use the hotkey to get your mouse and keyboard back, focused on your Mac
  2. Click the red close button in the upper left corner of the VM window
  3. You should see a prompt with three choices
  4. Choose “Save the machine state” and click OK

The VM window will close and you’ll be back in VirtualBox. The VM entry should say something like “IE6 (clean) / Saved.” This indicates two things:

  • “(clean)” refers to the original Snapshot, or the state of the VM when it was first installed. This is the magic trick for running the VM indefinitely. If you ever are unable to log in because Windows wants you to activate the software, this is the backup plan. Make sure the VM is closed, then go to VirtualBox and click the “Snapshots” button to view the available Snapshots. To restore the VM to its original state, select the “clean” entry and then click the “Restore Snapshot” button. You’ll have to go through the whole VM configuration process again, but this should work forever.
  • “Saved” refers to the current machine state. When you launch the VM the next time, it will be just as you left it – analogous to Hibernate.

Huzzah!

The good news is that you’re done configuring all the building blocks that you’ll need from here on out. From here, you need to download the other versions of IE that you want to test. There really shouldn’t be any other configuration that you need to do for the other browsers other than what’s outlined above. Keep in mind that IE6 is the only browser for which you need to install the network drivers – the others should work out of the box.

Installing IE7 – 9

To get the other VMs set up, just run the terminal command again, making sure to edit it for the next browser that you want to install. So:

  1. curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS=”7″ bash
  2. curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS=”8″ bash
  3. curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS=”9″ bash

Again, I recommend running these one at a time to avoid putting all your eggs in the same download basket.

After each one is finished downloading, you can return to VirtualBox and see that the new VM is available to launch.

You can follow a similar procedure for each subsequent browser for adjusting the display resolution and editing the Hosts file. Here are the UI steps you’ll need to follow for those (in case you’re not familiar with Windows):

  • IE7: Start > Control Panel > Personalization > Display Settings
  • IE8: Start > Control Panel > Appearance and Personalization > Display > Adjust Screen Resolution
  • IE9: Start > Control Panel > Display

The Hosts file will always be located in the same place (C:\Windows\System32\drivers\etc).

Here are abbreviated instructions for setting up the other VMs. If you’ve gotten IE6 to work, these should be a breeze.

IE7

  1. Update Network Settings in VirtualBox control panel. Use Bridged Adapter and choose the same connection method you did for IE6 (mine is en1: Ethernet 2). Refer back to System Preferences > Network if you can’t remember what it is.
  2. Start the VM
  3. Choose the Administrator account and use “Password1″
  4. When you’re asked to activate Windows, choose Activate Later
  5. Cancel or close all of the subsequent messages (Found New Hardware, Set Network Location, Restart etc)
  6. IE7 should be connected to the Internet at this point
  7. Configure display settings, hosts file
  8. When you want to close the VM, be sure to close the Mac window and choose “Save Machine State”

IE8

  1. Update Network Settings in VirtualBox control panel.
  2. Start the VM
  3. Administrator / Password1
  4. This VM can take a while to load the first time. Be patient.
  5. When you’re asked to activate Windows, choose Activate Later
  6. Cancel or close all of the subsequent messages (Found New Hardware, Set Network Location, Restart etc)
  7. IE8 should be connected to the Internet at this point
  8. Configure display settings, hosts file
  9. When you want to close the VM, be sure to close the Mac window and choose “Save Machine State”

IE9

  1. Update Network Settings in VirtualBox control panel.
  2. Start the VM
  3. Administrator / Password1
  4. This VM can take a while to load the first time. Be patient.
  5. When you’re asked to activate Windows, choose Activate Later
  6. Cancel or close all of the subsequent messages (Found New Hardware, Set Network Location, Restart etc)
  7. IE9 should be connected to the Internet at this point
  8. Configure display settings, hosts file
  9. For some reason this package contains tons of shortcuts on the Desktop. I deleted all of them except for IE9, Firefox, Chrome, and the shortcut to my hosts file.
  10. When you want to close the VM, be sure to close the Mac window and choose “Save Machine State”

Conclusion

Yes, it’s a lot of work. But I think it’s well worth it. Here’s what you’ll gain:

  • The ability to test websites locally on your Mac
  • The ability to test local websites in Windows from your Mac
  • The ability to test local websites in real versions of Internet Explorer – no emulation
  • The ability to do all of this without having to upload your files to an external server
  • And, though I haven’t mentioned it yet – you’re able to install any other Windows browser in any of these VMs.
  • It’s all free

You’ll of course become more familiar with the VM process, and pretty soon you won’t think it’s a big deal to revert to the (clean) snapshot.

Thanks for reading, happy testing!

Thomas Hopkins

Mar 8, 2012

That’s pretty cool! I love that the ievms script uses nothing fancier than unrar to extract the disk image from Microsoft’s installer executables.

Have you tried IE8 or IE9’s compatibility modes for testing as well? I find that it’s adequate for most issues. ...except for the 2% of issues that, thanks to the brightening fortune of Internet Explorer, will no longer appear. I’m interested to hear if you’ve seen any quirks or inconsistencies with it, though I know that there’s really no substitute for the native browser.

John Manning

Mar 9, 2012

Hey Thomas- Yeah, I used compatibility modes for a long time in a previous job where we used all Windows machines. They worked ok when testing 7 and 8, but when IE9 was released and it came to switching between three different versions it got to be too much. I also found there to be a really confusing difference between Browser Mode and Document Mode. I took the time to read about them at some point but was never convinced that I was actually testing correctly.

So, yes, I’ve used compatibility mode. I can’t think of any specific bugs that I tracked directly to using that method. Regardless, the multi-sandboxed-VM approach is worlds better.

Thomas Hopkins

Mar 12, 2012

I think the best part of the VMs is that they seem to exist in some weird (and maybe Microsoft-endorsed?) licensing limbo. As for the things that compatibility mode doesn’t get right, it seems like some of the hasLayout bugs that plague IE8 and especially IE7 don’t appear in compatibility mode for me. I’ll try to find an old file to see if I can find a specific instance.

Microsoft did fix their PNG rendering, so that’s at one relic of IE6 that we’ve lost: poor alpha channel support.

John Manning

Mar 13, 2012

Yes, these VM packages are based off of ones that Microsoft released specifically for testing IE. I believe that they were originally supposed to expire at some point, but using the snapshot approach means that if you ever need to reinstall it’s just a matter of restoring from that point.

Speaking of IE6 being terrible, I was amused to hear Happy Cog’s Jenn Lukas mention that it was pretty well received upon initial release. She was a guest on Jeffery Zeldman’s Big Web Show (ep 64), and said that since she was accustomed to working with Netscape 4 (I think) that IE6 was a big improvement. Maybe someday we’ll be saying that fixing stuff for Chrome 17.0.963.79 is a nightmare. But I doubt it :)

Thomas Hopkins

Mar 13, 2012

IE6 was fantastic when it launched, or, at least, I remember moving to it in favor of everything else. Microsoft did some impressive work, but it seems like they became content resting their laurels. There’s a great clip from one of Douglas Crockford’s Javascript presentations that shows how they went about it: http://youtu.be/Fv9qT9joc0M?t=1h11m2s

The relevant portion is only a few minutes long, but the entire video series is great—there’s a point in one of the videos where he says something to the effect of, “at one point in time, IE6 was the best browser.” I know that’s true for me. Makes me shudder.

Joella Molson

Mar 17, 2012

First off John, thank you so much for this tutorial. I know a lot of work went into this. And I appreciate that.

That being said I had no luck getting this to work for me. Are you using MAMP or MAMP Pro? Someone told me that it will only work with the Pro version and I am working a 0 budget so this leaves me out.

However, I tried using your excellent tutotial and some articles I found on Wordpress to try and get this working with Wordpress sites installed with AMPPS and I’m almost there.

I can get the windows IE to connect to a AMPPS directory page that shows my site and I can open the site. But the page that comes up is completely unstyled and shows no images.

When I click on a link to a post I get the dreaded “page cannot be displayed” error from IE.

I also used this article for setting up wordpress multisite for local network testing. (Though I’m not using multisite, this got me closer to success.):
http://wordpress.org/support/topic/wordpress-3-network-multisite-on-a-local-development-site

Here’s what I ended up doing.

I added this to my Macbook’s hosts file:
127.0.0.1 modularchameleon.wpdev

Then I added this to the virtual hosts file in the AMPPS Apache folder:

NameVirtualHost *:80

DocumentRoot “/Applications/AMPPS/www”
ServerName localhost

DocumentRoot “/Applications/AMPPS/www/modularchameleon.wpdev”
ServerName modularchameleon.wpdev

    AllowOverride All

In the Windows hosts file I added my Mac’s local web address and the name of the site:
192.100.X.XX   modularchameleon.wpdev

If you or any of your kind readers can see what I’ve done wrong I’d appreciate the input.

Again, thank you for this awesome tutorial. I would not have got this far without it.

Joella Molson

Mar 17, 2012

Oops so sorry - forgot to escape characters in that last bit. Should read:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot “/Applications/AMPPS/www”
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “/Applications/AMPPS/www/modularchameleon.wpdev”
ServerName modularchameleon.wpdev
<Directory “/Applications/AMPPS/www/modularchameleon.wpdev”>
    AllowOverride All
</Directory>
</VirtualHost>

Thomas Hopkins

Mar 17, 2012

Joella, it sounds like your “WordPress Address” setting is set to something other than http://modularchameleon.wpdev or the IP address of your Macbook plus the directory for the site (http://192.168.whatever.whatever/modularchameleon.wpdev). If you can load a page in IE that looks unstyled, WordPress probably just uses the wrong URL if you use something like bloginfo(‘stylesheet_url’) in your WordPress themes. (I know the prepackaged themes use it.)

Forgive me if you’ve already checked that out. It sounds like you’ve almost got it all working in any case!

Thomas Hopkins

Mar 17, 2012

I’m sorry—I should have been more specific. The “WordPress Address” setting is in WordPress’s “general settings” admin page.

Joella Molson

Mar 17, 2012

Thomas,

You may be onto something, the address showing in Wordpress is:

http://127.0.0.1/modularchameleon.wpdev

And this works completely on the Mac. This is also the the address that AMPPS has showing in the Wordpress Install list. I wish I had a better grasp on all this.

Oh, and my stylesheet is in the root folder of the WP install.

So what should I change? My settings in Wordpress or should I match the settings in the virtual hosts configuration file to the address that Wordpress is using?

I see a world of fiddling in my future. LOL

I’ll let you know how it goes. Thanks for pointing in this direction though, it gives me stuff work on.

John Manning

Mar 19, 2012

Joella,

Any luck getting this to work? As for MAMP vs MAMP Pro, plain old MAMP works perfectly well - I haven’t upgraded to Pro. I’ve never used AMPPS, but from what you’ve mentioned and a glance at its feature page it looks like it behaves just like MAMP but that it also includes Perl and Python.

Thanks for your input Thomas!

Aaron

May 29, 2012

I went through this step-by-step and it worked! Being able to quickly test Internet Explorer on my Macbook is going to make my life much easier. Thanks for putting this together.

Christian

Jul 21, 2012

Thank you so much for the excellent write-up. Works perfectly.

Dan

Oct 26, 2012

Totally awesome.

Quick note: in step one of subsection two of part the MAMPth you seem to have neglected to escape your >s and <s, leaving only a pair of confusing “”s visible to the average reader.

John Manning

Oct 26, 2012

Dan- thanks for catching that encoding error. It’s been updated and makes much more sense now.

Nic

Jan 15, 2013

Thanks for the guide.. When I launch IE9, I’m not able to connect to the internet. It says that the driver for the network adapter is missing. I installed the Guest Additions from the disk image, but no luck. Any advice for me?

Post a Comment