Search code examples
phpmacosinternet-explorer-8virtual

How to connect to PHP localhost web app through virtual machine IE browser?


Is there a way to connect from a Windows 7 virtual machine from Oracle VirtualBox to Mac Mountain Lion localhost php application?

The problem is some web apps need to be tested on that lovely IE, so hence the virtual machine; the development or host environment is Mac. The PHP web app was started via terminal command: php -S 127.0.0.1:port#.

Is there anyway from the virtual machine, can one use IE to browse the web app on the Mac host?

Tried WineBottler, IE8 constantly crashes there; Tried plain Wine, IE8 doesn't seem to respond at all, though it installs and opens, but freezes.

Last option is to connect through virtual machine or the long way via online server.

Thanks for the help!


Solution

  • Here's how I got this working for anyone interested:

    1. Find out the IP adresses of the host and guest systems.
      • Windows: ipconfig - IPv4 Address
      • Linux: ifconfig - inet addr
      • Mac: ifconfig -a
    2. From Oracle VBox Network settings, choose NAT adapter.
    3. Select Port Forwarding.
    4. Add a new rule with the plus sign.
    5. Give the rule a name, set protocol to TCP, set both ports to 80 and put the Ip adresses found out in step 1 in their respective fields.
    6. From your browser point to the Ip address of the guest if in host or vice-versa.

    Note: In my case, I needed to see my web app on the guest system, so I ran the app using the Ip address of my host and gave any port number (not in use). Then from the guest, I pointed to that Ip address and port number.

    Example:
    Assuming that the Ip address of the host is: 192.168.1.11
    From host terminal: php -S 192.168.1.11:3000
    From guest browser: 192.168.1.11:3000