I am a web developer and my development platform is Mac. I have installed a copy of Windows XP in VMWare fusion for testing purposes and using IE for previwing my websites. I have Apache running on my Mac with several subdomains, like test.localhost etc.
How can I access the webserver on host OS from the guest OS?
Thank you in advance.
VMWare Fusion registers an IP address on your Mac and you can use this to point to the host from the virtual machine. You can find it with ifconfig vmnet8
. Mine's 192.168.36.1, yours might be the same.
If you're using apache virtual hosts and you try to get http from this address on your virtual machine, it will probably display the default apache page. You'll need to map the domains on your windows host:
Open C:\WINDOWS\system32\drivers\etc\hosts
in Notepad and add your hostnames, 1 per line:
192.168.36.1 test.localhost
Then, when you put http://test.localhost/
in IE, it will route to your Mac's apache virtual host.
Using Fusion 6.0.2 on OS X 10.9 Mavericks
In the host system (Mac)
turn off your virtual machine
open the "Virtual Machine | Network Adapter | Network Adapter Settings..." menu
in the "Bridget Networking" section choose "Autodetect":
- turn on your virtual machine
In the guest system (Win7)
- right click on the Notepad application, then select "Run as administrator":
when Win7 asks: "Do you want to allow the following program to make changes to this computer?" click on the "Yes" button
navigate to: "Computer | Local disk (C:) | Windows | System32 | drivers | etc"
select "All files" in the drop down menu on the right of the "file name:" field
double click the "hosts" file
In the host system (Mac)
- open your system preferences and select "Network"; in your connected interface look for the Mac IP:
192.168.1.106 in the example
In the guest system (Win7)
- in your notepad window enter the Mac IP followed by the sites you want to reach in your host (Mac) system:
in the example I configured two sites: localhost and caeb.leo
- open the browser and you will be able to see the sites hosted on your host system:
Hope it helps!
Andrew's answer, while correct, is missing a significant portion, namely that vmnet8
is only used when the guest OS is set to use the Bridged network option.
If your guest OS is using the NAT network option, as seen in this Windows host example, you would need to use vmnet1
instead.
In this case, the IP of vmnet1
192.168.119.1 allows access to the host webserver, while the IP of vmnet8
leads nowhere.
note, I provide this answer for those who, like me, have the same question as the title but not the exact same specifics of running Apache as a raw local installation
double note, this answer is a mix of Andrew and Camaleo's answer since neither worked in my set up (not pointing to Mac's ip and Bridged Networking's "Autodetect" wasn't working for some reason?) , not sure if the inclusion of Docker Machine causes the hiccup
If you're setup is like so:
- (Host) Mac (example ip 192.168.1.249)
- (Guest) Docker Machine (example ip 192.168.99.102)
- Apache (port 80)
- VMware Fusion 10
- (Guest) Windows 10 (example ip 192.168.68.142)
- (Guest) Docker Machine (example ip 192.168.99.102)
Step 1
From within Windows 10 VM open Notepad as Administrator (right click notepad for the option). Navigate to C:\Windows\System32\drivers\etc
and instead of Text Documents(*.txt)
select All Files
. Open the hosts
file and add a hosts entry for your Docker Machine's IP(via docker-machine ls
). Per our above example setup, the line would look like so:
192.168.99.102 myapp.test # or some other fitting name
Save changes.
Step 2
Note: No need to stop or restart your virtual machine in VMware Fusion 10 when making network changes.
From VMware Fusion Menus select Virtual Machine
/ Network Adapter
/ Network Adapter Settings
. Choose Share with my Mac
.
if "Share with my Mac" is already selected, select a different network adapter option (like Bridged Network Automatic) and then re-select "Share with my Mac" to ensure host file changes are taken
Step 3
Test changes are in place from within Windows VM by pinging the desired address (e.g "myapp.test" as shown above) or by opening Edge/Chrome checking if the webpage loads
note, using a domain name that ends in .test
is recommended or Chrome may still have issues with HSTS errors
来源:https://stackoverflow.com/questions/3235011/vmware-fusion-connecting-to-hosts-web-server-from-guest