Posted on March 21, 2013 by Curtis McHale

Local Testing with Windows in Virtualbox

We’re jumping out of our series since I had to set up local testing and figured that passing on the information is a good thing. Next week we’ll get back to our plugin that allows users to save posts for later.

If you’re developing locally (and you really should be) you’re going to need to figure out a strategy to test your site in other operating systems and other browsers.

Today we’re going to set up local testing for Windows running on Virtualbox inside Mountain Lion.

If you prefer a screencast jump to the bottom.

Local Testing in Virtualbox

I assume that you already have Virtualbox setup with Windows 7. If not then you really need to go get it.

So run your Windows 7 install on Virtualbox. The first step is finding our Hosts file. If you didn’t know already, this file routes all your internet traffic to it’s locations. By default it’s just going to send it out to the Word Wide Web, but we’re going to tell it to send some sites to our local MAMP domain.

In Windows 7 you can find the file at C:\Windows\System32\drivers\etc. Now click on it and open in your favourite text editor.

Now we need to find the IP address of our local machine. Open Terminal.app and type in ifconfig. What you’re looking for is the number after the inet entry. In my case it’s 10.0.1.131 and we’re going to use that number in our Windows hosts file to point a domain at our local environments.

terminal.app ifconfig

So now we type in to our hosts file 10.0.1.131 local.maritinque.org (since I’m setting this up for my local testing site at local.martinique.org). When you try and save the file, you’re going to be told that you can’t save it.

This is a security setting in Windows designed to make sure that phishing/hackers can’t change how your computer accesses the web. Close your text editor and then go to the start menu and find it again. Right click and choose the ‘Run as Adiminstrator’ option.

Windows - run as administrator

I use Sublime text 2 and it will open the edited file for me, but in Administrator mode. Now save the file.

edited hosts file

It’s likely that you’re going to have to close your web browsers then open them. Navigate to your local testing domain, and you should see it all set for testing.

Screencast