Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running OSX MAMP test server on VirtualBox Windows 7

I have MAMP server and several test sites installed on my OSX 10.6.3. I just installed Windows 7 on a VirtualBox virtual machine. I have managed to successfully share folders to the Windows installation, but I am wondering if I can run my MAMP sites in Windows without installing a different Localhost there.

Does anyone know if this is possible? It would be very convenient if I could test my sites in both operating systems all hosted from a single location.

like image 598
Logic Artist Avatar asked Jul 24 '10 17:07

Logic Artist


3 Answers

Although this is probably too late for the OP, posting here for others.

If you're just trying to access your Mac localhost, then all you need to type into the guest os is 10.0.2.2.

If you're trying to access named virtual hosts such as 0.dev or dev.local, then you need to modify the guest os host file to map the domain names to the host os.

In the case of Windows 7, you simply navigate to C:\Windows\System32\drivers\etc then modify the hosts file with admin privs.

Inside you will you will see the following line commented out

# 127.0.0.1    localhost

Below it, add entries for each of the virtual hosts you wish to use

10.0.2.2    maclocalhost
10.0.2.2    0.dev
10.0.2.2    dev.local
like image 135
Jon Jaques Avatar answered Oct 18 '22 10:10

Jon Jaques


I just setup three VirtualBox VMs today specifically for connecting to MAMP on an OS X host. Thought I’d share my method of doing this since it works well for me.

While accessing the localhost via 10.0.2.2 I find using a host only network to be a much more flexible & reliable way to handle scenarios. You get a another IP address so debugging network issues on a VM can work as well.

First, go to VirtualBox -> Preferences…. Then choose Host-only Networks. You should have a vboxnet0 adapter in place. If not, add one.

enter image description here

Once you are set with that, select the vboxnet0 adapter & click the small yellow screwdriver icon on the right side of that window to edit the options. Under the Adapter pane, set the IPv4 address to 192.168.56.1 & the network mask to 255.255.255.0. Leave the IPv6 area blank. The IPv6 network mask length should be 0.

enter image description here

The DHCP server stuff should be blank, like so.

enter image description here

Okay? Got that set. Now choose your VM. In my example it’s the IE8 - Win7 image for web development testing. And click the Settings gear. Then click the Network icon. And now choose Adapter 2. And choose Host-only Adapter from the pull down menu for Attached to:. And then choose vboxnet0 under Name:. The rest of the options should just be the standard options.

enter image description here

Now, when you startup your Windows VM, launch Internet Explorer. And go to the address:

http://192.168.56.1

With that, you should be set! But if you are used to using Macs, be 100% sure you have the http:// in front of the address. I got embarrassingly stuck when I just entered the straight 192.168.56.1.

And as Jon Jaques says in his answer you can edit the hosts file in Windows to point to the IP address of 192.168.56.1. It will make your life easier & if you know how to setup named virtual hosts in MAMP (not hard) you can setup a few different sites to test via VirtualBox.

Oh, also, if you are used to using your machine name in OS X to connect to MAMP—like with the name LogicArtist.local if that is your machine’s name—you are not in any luck. The VirtualBox built in software router claims to pass multicast data, but it doesn’t. Check out this post which explains it in more detail.

In the environment created by VirtualBox there are multiple NICs that claim to be multicast capable. However, they are lying. Furthermore, because of the way VirtualBox assigns metrics, your outgoing socket will get assigned to a liar who will happily gobble up your multicast messages and not send them on.

Annoying, but you can work around stuff like that by at least editing your hosts file to have an entry for LogicArtist.local like this:

192.168.56.1    LogicArtist.local

Definitely not as elegant as a true multicast address being passed, but at least the brief amount of time you will be spending in Windows to debug things will be made easier but adding that entry.

like image 24
Giacomo1968 Avatar answered Oct 18 '22 08:10

Giacomo1968


MAMP Pro lets you specify the port for each host. Choose a unique port for your desired host. In your virtual machine simply type http://10.0.2.2:PORTNUMBER and your site will appear. Example: I created a host called localuproar and assigned it port number 9000. In VirtualBox I opened up Internet Explorer and typed http://10.0.2.2:9000, and my site appeared.

You can mess around with hosts files as described in previous posts, but I think it is easier to simply type in a port number.

On a related note, there is a very easy way to create virtual machines for all versions of Internet Explorer (http://osxdaily.com/2011/09/04/internet-explorer-for-mac-ie7-ie8-ie-9-free/):

  1. Launch Terminal
  2. Type this in your terminal window

    curl -s https://raw.githubusercontent.com/xdissent/ievms/master/ievms.sh | bash

enter image description hereenter image description here

like image 38
Jon Avatar answered Oct 18 '22 09:10

Jon