Accessing to MAMP localhost from a Windows virtual machine for testing browser compatibility

Why accessing to your Mac localhost (web server) from a Windows virtual machine? Easy! Because Internet Explorer sucks. So you could need to test your website on IE and the most reliable way is to test it on a “real” Windows installation. Here we go.

Workflow:

Solution 1 (the simpliest one)

  1. Start the Windows VM
  2. Open IE and enter the URL http://10.0.2.2:8888 (8888 is the default Apache port in MAMP). Done! You will see your web server root, but if you navigate through the pages of a site you will notice that the links are broken, cause they are related to http://localhost:8888. So…
  3. Open the hosts file placed in C:\WINDOWS\system32\drivers\etc and add this line:
    10.0.2.2    localhost
  4. This time it’s really done! Enter in IE the URL http://localhost:8888 and navigate through your sites.

 

Solution 2

Try this solution if the previous one doesn’t work, but I have to warning that this solution (for me) worked only sometime.

  1. Open VirtualBox > Preferences > Network > Host-only Networks tab and click the icon for adding an host-only network. This will creates a new network called, in my case, vboxnet0. Click OK.
  2. On the left VirtualBox list of VMs click on the one you’re interested then right click on it > Settings > Network and click on the first available Adapter tab.
  3. Here select these settings:
    1. Attached to: Host-only adapter
    2. Name: vboxnet0 (or the name of your new network)
  4. Click OK and launch that VM.
  5. While the Windows starting, launch the Terminal (on Mac) and enter this command:
    ifconfig vboxnet0

    You will see and IP address like inet 192.168.56.1

  6. Go back to Windows VM, open the hosts file in C:\WINDOWS\system32\drivers\etc and add this line:
    196.168.56.1    localhost:8888
    

    Notice: on MAMP you reach the web server root on localhost:8888, replace it if you’re on another port

  7. Finally, open your most favorite browser ever (IE) and enter http://localhost:8888 (be sure to enter http:// because IE is a really beautiful but pedantic guy) and you should see your web server root.

 

References

http://stackoverflow.com/a/13026989/1252920

http://justinmarsan.com/accessing-localhost-in-mac-osx-from-windows-vm-in-virtualbox/

http://stackoverflow.com/a/21128108/1252920

  • NewmanOZ

    Thanks

Categories

Category BootstrapCategory CoffeescriptCategory DrupalCategory GravCategory HTMLCategory JavascriptCategory JoomlaCategory jQueryCategory LaravelCategory MagentoCategory PHPCategory SharePointCategory SpringCategory ThymeleafCategory WordPressCategory Workflow

Comments

Developed and designed by Netgloo
© 2019 Netgloo