VMWare fusion:从访客连接到主机的 Web 服务器
我是一名Web开发人员,我的开发平台是Mac。我在 VMWare fusion 中安装了一份 Windows XP 副本用于测试目的并使用 IE 预览我的网站。我的 Mac 上运行着 Apache,其中包含多个子域,例如 test.localhost 等。
如何从来宾操作系统访问主机操作系统上的 Web 服务器?
先感谢您。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 OS X 10.9 Mavericks 上使用 Fusion 6.0.2
在主机系统 (Mac) 中
关闭虚拟机
打开“虚拟机 | 网络适配器 | 网络适配器设置”。 ..”菜单
在“Bridget 网络”部分中选择“自动检测”:
在来宾系统 (Win7) 中
当 Win7 询问时:“您想要允许以下程序对此计算机进行更改吗?”
单击“是”按钮
导航至:“计算机 | 本地磁盘 (C:) | Windows | System32 | 驱动程序 | 等”
在“文件名:”字段右侧的下拉菜单中选择“所有文件”
在“文件名:
双击“hosts”文件
在主机系统 (Mac) 中
示例中的 192.168.1.106
在记事本窗口的来宾系统 (Win7)
在示例中,我配置了两个站点:localhost 和 caeb.leo
希望有帮助!
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":
In the guest system (Win7)
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)
192.168.1.106 in the example
In the guest system (Win7)
in the example I configured two sites: localhost and caeb.leo
Hope it helps!
VMWare Fusion 在您的 Mac 上注册一个 IP 地址,您可以使用它从虚拟机指向主机。您可以使用
ifconfig vmnet8
找到它。我的192.168.36.1,你的可能是一样的。如果您使用 apache 虚拟主机并尝试从虚拟机上的此地址获取 http,它可能会显示默认的 apache 页面。您需要在 Windows 主机上映射域:
在记事本中打开
C:\WINDOWS\system32\drivers\etc\hosts
并添加您的主机名,每行 1:然后,当您输入 < code>http://test.localhost/ 在 IE 中,它将路由到 Mac 的 apache 虚拟主机。
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:Then, when you put
http://test.localhost/
in IE, it will route to your Mac's apache virtual host.Andrew 的答案虽然正确,但缺少重要部分,即
vmnet8
仅在以下情况下使用来宾操作系统设置为使用桥接网络选项。如果您的来宾操作系统使用 NAT 网络选项(如本 Windows 主机示例所示),您将需要使用
vmnet1
。在本例中,
vmnet1
的 IP 192.168.119.1 允许访问主机网络服务器,而vmnet8
的IP无处可去。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 ofvmnet8
leads nowhere.注意,我为那些像我一样有与标题相同的问题但不完全相同的细节的人提供这个答案
双重注意,这个答案是Andrew 和 Camaleo 的答案的混合,因为在我的设置中都不起作用(没有指向 Mac 的 ip 和桥接网络的“自动检测”由于某种原因不起作用?),不确定包含 Docker Machine 是否会导致打嗝
如果您的设置如下:(
步骤 1
在 Windows 10 VM 中以管理员身份打开记事本(右键单击记事本选项)。导航到
C:\Windows\System32\drivers\etc
,然后选择所有文件
,而不是文本文档(*.txt)
。打开hosts
文件并为 Docker 机器的 IP 添加一个主机条目(通过docker-machine ls
)。根据我们上面的示例设置,该行将如下所示:保存更改。
步骤 2
注意:进行网络更改时,无需在 VMware Fusion 10 中停止或重新启动虚拟机。
从 VMware Fusion 菜单中选择
虚拟机
/网络适配器< /code> /
网络适配器设置
。选择与我的 Mac 共享
。如果已选择“与我的 Mac 共享”,请选择不同的网络适配器选项(例如桥接网络自动),然后重新选择“与我的 Mac 共享”以确保进行主机文件更改
第 3 步
从 Windows VM 内进行测试更改
通过 ping 所需的地址(例如“myapp.test”,如上所示)或通过打开 Edge/Chrome 检查网页是否加载note(使用以
.test
,否则 Chrome 可能仍会出现 HSTS 错误问题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:
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 ofText Documents(*.txt)
selectAll Files
. Open thehosts
file and add a hosts entry for your Docker Machine's IP(viadocker-machine ls
). Per our above example setup, the line would look like so: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
. ChooseShare 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