macos 从 Mac 访问 Parallels Windows 本地主机

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2673595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:53:32  来源:igfitidea点击:

Access Parallels Windows localhost from Mac

macoswindows-7localhostvirtual-machineparallels

提问by Ranch

I use Windows (7) OS as a development platform, running on a Mac / Parallels Desktop 5.

我使用 Windows (7) 操作系统作为开发平台,在 Mac / Parallels Desktop 5 上运行。

I would like to access the Windows localhost - from the Mac side for testing purposes.

我想从 Mac 端访问 Windows 本地主机以进行测试。

I've found many solutions of accessing the other way around (access Mac's localhost from Windows) - but found no solution for this access direction (if any).

我找到了许多以其他方式访问的解决方案(从 Windows 访问 Mac 的本地主机) - 但没有找到针对此访问方向的解决方案(如果有)。

Any idea ? Is it possible ?

任何的想法 ?是否可以 ?

采纳答案by Arefin

I had the same problem as you Ranch. I'm running Win7 on Mac OS X (Snow Leopard) / Parallels 5. I solved my localhost problem on mac , by turning off win7 firewall and "enable" anonymous authentication in Authentication setting in IIS Manager.

我和你的牧场有同样的问题。我在 Mac OS X (Snow Leopard)/Parallels 5 上运行 Win7。我通过关闭 win7 防火墙并在 IIS 管理器的身份验证设置中“启用”匿名身份验证,解决了我在 mac 上的本地主机问题。

Also I've configured in parallels:

我也平行配置:

  1. Configure - hardware - Network adapter 1: Default Adapter

  2. Preferences - network - connection type - shared networking

  1. 配置 - 硬件 - 网络适配器 1:默认适配器

  2. 首选项-网络-连接类型-共享网络

Edit: For Parallels 8

编辑:对于 Parallels 8

  1. Configure > Hardware > Network adapter 1: Default Adapter

  2. Preferences > Advanced > Network: Change Settings> Shared

  1. 配置 > 硬件 > 网络适配器 1:默认适配器

  2. 首选项 > 高级 > Network: Change Settings> 共享

回答by Akku

The above didn't help me, but this did:

以上对我没有帮助,但这确实帮助了我:

  • Go to Windows VM, go to Start --> Run... --> type cmd.exe

  • The windows command line opens. Type ipconfigand find out your IP4-adress.

  • Edit your macs hosts file as described in this blogpost. Put in the following line, replacing my windows VMs local IP (here 10.211.55.5) with the one you found out in the step before:

    10.211.55.5   windows
    
  • 转到 Windows VM,转到开始 --> 运行... --> 键入 cmd.exe

  • Windows 命令行打开。输入ipconfig并找出您的 IP4 地址。

  • 按照本博文中的说明编辑您的 mac 主机文件。输入以下行,将我的 Windows VM 本地 IP(此处为 10.211.55.5)替换为您在之前的步骤中发现的 IP:

    10.211.55.5   windows
    

Then, you can access the localhost of windows using win instead of localhost, for example http://windows:8080/someapp

然后,您可以使用win而不是localhost访问windows的localhost,例如 http://windows:8080/someapp

回答by matei

This depends on how your network card is setup in the virtual machine. I don't know how it is in parallels, but in VMWare Fusion you can either set it up as "bridged" (which means sharing the same ip with the host), "NAT" which means it will have it's own private ip address and connect to the internet through the host , or "Private network" which means it will have a private IP address and will not connect to the internet. In the second and third case you can access the web server running on windows using the private ip address of the virtual machine, but in the bridge case I don't think this can be done.

这取决于您的网卡在虚拟机中的设置方式。我不知道它是如何并行的,但是在 VMWare Fusion 中,您可以将其设置为“桥接”(这意味着与主机共享相同的 ip),“NAT”,这意味着它将拥有自己的私有 ip 地址并通过主机或“私有网络”连接到互联网,这意味着它将拥有一个私有 IP 地址并且不会连接到互联网。在第二种和第三种情况下,您可以使用虚拟机的私有 IP 地址访问在 Windows 上运行的 Web 服务器,但在桥接情况下,我认为这无法做到。

回答by Coxy

Sounds to me like your Parallels config is set to Host-Only networking for the Guest. Switching to Shared Networking should give your guest Windows OS a local IP address.

在我看来,您的 Parallels 配置被设置为 Guest 的 Host-Only 网络。切换到共享网络应该为您的来宾 Windows 操作系统提供本地 IP 地址。

Then, you will have to access the Windows local IP address (not127.0.0.1) from the Mac browser. You can find out the IP address to use by opening a command prompt in the Windows guest and taking a look at the output of the ipconfigcommand.

然后,您必须从 Mac 浏览器访问 Windows 本地 IP 地址(不是127.0.0.1)。您可以通过在 Windows 客户机中打开命令提示符并查看ipconfig命令输出来找出要使用的 IP 地址。

回答by criscom

I have followed the instructions above and Akku's provided the important hint, although for me it did not work. When I run ipconfig in the windows command line, I get 10.211.55.3 as an IPv4-Address and 10.211.55.1 as the standard gateway. Using 10.211.55.3 in the windows hosts file (C:\Windows\System32\drivers\etc\hosts) did not work - not sure why. So I tried: 10.211.55.2 and it worked.

我遵循了上面的说明,Akku 提供了重要的提示,尽管对我来说它不起作用。当我在 windows 命令行中运行 ipconfig 时,我得到 10.211.55.3 作为 IPv4 地址和 10.211.55.1 作为标准网关。在 windows 主机文件 (C:\Windows\System32\drivers\etc\hosts) 中使用 10.211.55.3 不起作用 - 不知道为什么。所以我尝试了: 10.211.55.2 并且它起作用了。

Summing up: you have to set up your apache virtual host config first as described and then you have to open: C:\Windows\System32\drivers\etc\hosts and enter: 10.211.55.2 mysite.localhost (or whatever you defined in your virtual host config file). Hope this helps for those with the same problem as me.

总结:您必须首先按照描述设置您的 apache 虚拟主机配置,然后您必须打开:C:\Windows\System32\drivers\etc\hosts 并输入:10.211.55.2 mysite.localhost(或您在您的虚拟主机配置文件)。希望这对和我有同样问题的人有所帮助。

I found this here: http://sirprize.me/scribble/accessing-localhost-on-lion-host-with-windows-guest-on-parallels/

我在这里找到了这个:http: //sirprize.me/scribble/accessing-localhost-on-lion-host-with-windows-guest-on-parallels/