One of the reasons I like Mac OS X on Intel is because it provides the best of all worlds for a web designer. You use a Mac to build and test stuff, get a built-in Apache server, and you can run Windows—in a window.

However, if you want to run multiple websites and also test them in the virtual machine, you have to jump through some hoops. They’re not very difficult hoops, but if you’re not hugely technically minded, it pays to have some advice. So, here’s how I got everything up and running on my new Mac earlier today. Note that I’m using Windows XP and so your mileage may vary for other flavours of Windows.

  1. Create folders within ~/Sites and bung your websites in them.
  2. Install VirtualHostX. This $19 app saves faffing about with your Mac hosts file, doing the heavy lifting for you. For each site, click ‘Add Host’, type in a domain (such as reverttosaved.site) and define a local path (as in, the relevant folder within ~/Sites).
  3. Click ‘Apply Changes’ and VirtualHostX will do its thing. At this point, you should be able to view multiple sites in Mac browsers, using the defined domain names.
  4. Open System Preferences, click Sharing and make a note of the IP address under ‘your computer’s website’.
  5. Launch VMware Fusion and ensure it uses bridged networking for your VM. (Virtual Machine > Settings > ‘Connect directly to the physical network’.)
  6. Go to C:\WINDOWS\system32\drivers\etc and open the hosts file in Notepad.
  7. For each domain, type the IP address from step 4, then a space or tab, and then the domain (e.g. 192.000.1.99 www.reverttosaved.site) on its own line. Save the hosts file.
  8. Go to Start > Run, type cmd to open a command-line window. Type ipconfig /flushdns to flush the DNS resolver cache.
  9. You should now be able to access your domains via browsers in your Windows VM. Note that steps 6 through 8 need repeating for any additions to VirtualHostX, so it’s worth sticking a shortcut to hosts on your Windows desktop.

All this might be obvious to you, in which case, well done, Mr Geeky Pants. For me, it was a little journey of discovery, and so I hope this quickfire tutorial might help you if you’re not used to mucking about with hosts files.