Make your XAMPP site on your Mac accessible to Windows on VMware

How to run a site on a Mac host machine and then access it from Windows?

You may find your self here because you want to test IE browsers on the Mac. I have provided information on how to vet this issue along with the VM issue.

How to test IE on a Mac?

If you want to develop a website with XAMPP on your Mac (OSX), but test the site in Internet Explorer (IE) on a VMware Fusion Windows Image then you have found the right article. If you are just trying to serve a site from your Mac host machine to your local virtual machines this article is still useful despite its focus on the discussion around IE.

Alternatives for IE testing?
For those of you who are here because you want to test IE in a virtual machine on VMware Fusion you should first consider a few alternatives.

0/4 stars
The tried and true way to test IE is by having a different installation of IE running on a separate Windows box for each version of IE. To do this you could partition your Mac drive to run a different install of Windows for each version of IE. That sounds like a nightmare, but it is an alternative to using VMware.
Pros: Windows will run at highest performance
Cons: Difficult instillation. You can't serve the site from your Mac and then load it in Windows, you'll have to use outside hosting.

1/4 stars
The other thing you can do is run IE 10 on Windows 7 in a VM and then use the IE emulator using compatibility (or compat) mode to test older versions of IE. I personally do not trust this as I have seen IE 7 perform differently in the emulator than it has when running the true native version. But this should work for 90% of cases and drastically reduces the amount of trouble you have to go to to install so many Windows images. IE 11+ does not have compatibility mode so this will not allow you to test IE11+. See this thread for more information on compatibility mode.
Pros: You don't need to waist hard drive space with multiple Windows images
Cons: It will not always behave the same as a real install, not supported IE11 or greater. You have to buy VMware and Windows.

3.8/4 stars
There is a way that I have not been able to get to work on OS X Mountain Lion (at the time of this article), but it works for some and looks awesome. This is using the Oracle Virtual Box software to run different versions of IE. See this link here to try it out.
Pros: You don't have to pay for VMware Fusion. You don't have to buy a license of Windows. You can test all browser versions.
Cons: Oracle Virtual Box can lag in compatibility behind newer versions of the Mac OS.

3.8/4 stars
Finally Windows has gotten its butt in gear and provided the tools we need. You can download a few virtual machines to test each version of IE without the whole Microsoft OS. They provide all kinds of solutions. Virtual box, above, being one of them. The problem with this is it may not function as well as running an actual version of Windows and IE. Some claim it is prone to the same problems that compatibility mode had in < IE11. I can't confirm that. I can only say that this is as close as you can get to the gold standard of testing without using VMware.
Pros: You don't have to pay for VMware Fusion. You don't have to buy a license of Windows. You can test all browser versions.
Cons: Might not always behave exactly the same as a real install of IE, but it probably will.

4/4 stars
Using VMware and multiple OS is not an alternative, but it is the method this article teaches you how to set up. I only provide it here to reiterate that this is the most reliable method of testing.
Pros: It behaves like the real thing because it practically is the real thing.
Cons: Need a license of VMware Fusion, Windows 7, 8 and greater for IE 9+

OK so if you have decided to stick with the gold standard in testing let us continue.

What is VMware Fusion?
VMware Fusion is software that you can use to run other operating systems on a virtual machine. What exactly is a virtual machine? Suffice to say, that running Windows in a VM on your Mac allows you to run Windows like an application with its own window inside of the Mac OS. In other words it allows you to run both your Mac OS and your Windows OS at the same time.

What is a VMware Fusion Windows Image?
After you have set up VMware Fusion on your Mac, you will create a Windows Image. This is basically the windows operating system plus a snap shot of how it was running in memory. Suffice to say that this allows you to freeze Windows without shutting it down. It's kind of like hibernating or sleeping the operating system. It allows you to pause the operating system and save where it as an Image or Snapshot to your hard drive for later when you revive the system, same as if you closed your Mac laptop and then opened it later to resume work where you left off. Think of it as a virtual laptop running as an application on your Mac.

Why do I need VMware Fusion?
Since there is no version of IE available for the Mac, to fully see what a Windows user sees when they access your website requires that you have a copy of Windows. VMware Fusion allows you to run that copy of Windows on your Mac (you could of course dual boot Windows along with OSX as described above in alternatives). Secondly if you want to run several versions of IE, then with VMware Fusion, you can set up multiple Windows Images each with its own version of IE.

Setting up the software:
I won't go into much detail here as you can find documentation on how to do the following five steps easily. After you have done these following five steps, come back for the more difficult part of configuring the software.

1.) Buy VMware Fusion (yes you have to pay for it)
2.) Buy Windows (yes you have to pay for it)
3.) Install VMware Fusion on your Mac
4.) Set up and install Windows as a VMware image.
5.) Install XAMPP (keep in mind that if you secure XAMPP you might not be able to reach your web page from the VM)

Configuring VMware, your Mac and Windows:

1.) Run VMware on your Mac
2.) Boot up your Windows Image using VMware
3.) Find the VMware menu on your Mac
4.) Click "Virtual Machine" on the Apple menu at the top
5.) Select "Network Adapter"
6.) Select and click "NAT"
7.) Open a terminal window on your Mac
8.) Type into your terminal window on your Mac, ifconfig and hit enter (yes ifconfig not ipconfig the f is not a typo)


9.) Find the following:

vmnet1: flags=8863 mtu 1500
ether 00:50:56:c0:00:01
inet netmask 0xffffff00 broadcast

10.) Copy the inet (in this case
11.) Find on Windows your host file (in XP it is in C:\WINDOWS\system32\drivers\etc\hosts for how to find the hosts file in Windows 7 see this link)
12.) Open Notepad in Windows (in XP it is in Start > All Programs > Accessories > Notepad)
13.) Drag and drop the file hosts on Notepad and you should see something like the following:

# Copyright (c) 1993-1999 Microsoft Corp.
etc. etc. etc...
# For example:
# # source server
# # x client host localhost

14.) Remove the and replace it with the inet you copied in step 10. (inet is the vm network adapter ip for your Mac) (Keep in mind this will disable the localhost name on your VM, so if you have a web server installed on your VM you will no longer be able to access it using localhost) localhost

15.) If you are are running any subdomains on your Mac then add them to the bottom like the following: localhost tests.localhost

16.) Or any URLs that you have set up locally on your Mac XAMPP install localhost tests.localhost

17.) If you need a non standard port number you can't do it in a windows hosts file, but you can do it in the Mac hosts file (see step 20) localhost

18.) Save the Window's hosts file
19.) Find on your Mac the hosts file (usually in /etc/hosts)
20.) Repeat steps 14 to 17 but instead of using use so it would look like the following on your Mac hosts file: localhost tests.localhost localhost

21.) In the Windows VM run the command line window (in XP Click Start > Run and then enter cmd into the "open" text field and then click OK)

22.) In the Windows command line run the following:

ipconfig /flushdns

23.) If you are using custom domains like test.localhost or some you need to make sure that your httpd-vhosts.conf file is correctly configured on your Mac. See "How to Set Up A Subdomain with XAMPP" for more details.
24.) Make sure that XAMPP is running on your Mac and then restart it by running the following on the command line in your Mac under terminal:

sudo /Applications/XAMPP/xamppfiles/xampp restart

25.) Check to make sure it is loading on your Mac by opening a browser and going to http://localhost
26.) If it doesn't work you need to resolve this before testing it on Windows.
27.) Open a browser in the Windows VM and go to http://localhost and the same webpage you saw on your Mac should show up.
28.) You are officially set up.

There are lots of permutations of this article on the web, but I have found them to be sparse in their explanations. In this article I have tried not to assume you know everything but assume you know at least a few things being that you are a web developer. After you have completed these instructions there are few things you might want to know about what you just did. I'll try my best to anticipate your questions below:

What is the VMware Fuse Network Adapter?
This is how you want the Windows virtual machine to connect to the network via your Virtual Network Adapter. Because Windows is running on a virtual machine it means the hardware is virtual, this the network card and set up are virtual as well. This means you can change the network set up of your windows box simply by changing the VMware Fuse settings and voila as far as Windows cares it is running with a new set up. There are a few different settings under the VMware Fuse Network Adapter: NAT, Bridge and Host Only. (For more information on these check out the VMware documentation )

What is the NAT Network Adapter setting?
This means that the Windows VM does not have its own IP address on the external network. It instead lives on a Private Virtual Network that is set up on the Mac host operating system. That is to say the main OS that is running VMware Fuse. We use this instead of others because it protects the Windows operating system from being accessed from outside of your Mac. When you typed in ifconfig in your Mac Terminal (command line) you may have noticed in the list the vmnet8 entry. This is the address of the NAT network. If you were to run multiple VMs simultaneously they would all communicate via this private network via vmnet8. You might notice that vmnet8 exists on your system after you install VMware Fuse even when you are not running it. It is there to ensure the IP does not change as a permanent gateway into your virtual network. When you boot up an image in NAT each obtains its own IP using DHCP (dynamic IP allocation) and you can use these IPs to allow each VM to network with each other, but that is beyond what is necessary to know in order to access XAMPP on the host machine, in this case your Mac.

What is vmnet1 in ifconfig?
When you install VMware Fuse it creates a permanent address for you the network vmnet8. It is through the address at vmnet1 that the Windows Virtual Machine can access the host machine. This is why we use the NAT Network Adapter so that we can route the name localhost to the host machine via the address assigned to vmnet1. This assures that you don't have to change the hosts file every time you boot up as you would if you used the bridge setting.

comments powered by Disqus