WSL2:ddev 站点无法在 Windows 端的 Web 浏览器中加载

发布于 2025-01-16 14:11:18 字数 852 浏览 3 评论 0原文

我按照 https://ddev.readthedocs.io/ 在 Windows 10 上设置 ddev、ubuntu 18.04 和 wsl2 en/stable/ 指南 和视频 https://www.youtube.com/watch?v=ZMfHaUkhfc0

Ubuntu 20.04 https://www.microsoft.com/en-gb/p/ubuntu-2004/9n6svws3rx71?rtc=1#activetab=pivot:overviewtab 不可用,这是我之前使用的,我可以无法让它工作我设置了一个垃圾项目,但无法在我的网络浏览器(chrome)中加载它 https://junk.ddev.site/ 我刚刚收到以下消息“无法访问此网站,请检查 junk.ddev.site 中是否存在拼写错误。 如果拼写正确,请尝试运行 Windows 网络诊断。 DNS_PROBE_FINISHED_NXDOMAIN”我将这个 junk.ddev.site 127.0.0.1 添加到我的主机文件中,但它仍然无法工作。

I setup ddev, ubuntu 18.04 and wsl2 on windows 10 following the https://ddev.readthedocs.io/en/stable/ guide
and video https://www.youtube.com/watch?v=ZMfHaUkhfc0

Ubuntu 20.04 https://www.microsoft.com/en-gb/p/ubuntu-2004/9n6svws3rx71?rtc=1#activetab=pivot:overviewtab is not available which is what I used before and I can't get it to work I set up a Junk project but I can't get it load in my web browser (chrome) https://junk.ddev.site/ I just get the following message "This site can’t be reached Check if there is a typo in junk.ddev.site.
If spelling is correct, try running windows network Diagnostics.
DNS_PROBE_FINISHED_NXDOMAIN" I added this junk.ddev.site 127.0.0.1 to my host file but it still wouldn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

未央 2025-01-23 14:11:18

2 个选项:

选项 1 - 在 WSL2 中从 Ubuntu 运行 chrome

选项 2 - 更改 Windows 端的主机文件,将行编辑为:127.0.0.1 junk.ddev.site

我发现这两种方法都有效。

我发现选项 1 适用于 Windows 11 - 请参阅:在 Ubuntu 中使用 Google Chrome在 Windows 子系统 Linux在适用于 Linux 的 Windows 子系统上运行 Linux GUI 应用。 Windows 10 上的 WSL2 中的 GUI 应用程序显然也可用,但我还没有在那里尝试过:请参阅如何在 Windows 10 上安装 Linux GUI 应用。它之所以有效,是因为它避免了 WSL2 上的 Ubuntu 和 Windows 之间明显的网络问题。就好像您有一个运行 ddev 和 chrome 的普通 Linux 机器。

我发现选项 2 适用于 Windows 11 和 Windows 10。编辑 /etc/hosts 文件的 Windows 等效项 C:\Windows\System32\drivers\etc\hosts< /code> - 此文件存在于 Windows 11 和 Windows 10 上。您需要以管理员身份运行文本编辑器才能编辑它,如果您在文本编辑器的“文件打开”对话框中使用过滤器,请将其设置为“全部”,以找到所有文件不仅仅是 .txt 文件 - hosts 没有文件扩展名。

因此,对于您来说,@hobbsie,您在 C:\Windows\System32\drivers\etc\hosts 中所做的更改将是:

127.0.0.1 junk.ddev.site >

如果 hosts 中已经存在以 127.0.0.1 开头的行,请将其注释掉以供将来使用,但使其不处于活动状态。

参考文献:

2 options:

Option 1 - Run chrome from Ubuntu in WSL2

Option 2 - Change the hosts file on the Windows side, Edit line to be: 127.0.0.1 junk.ddev.site

I have found both of these to work.

Option 1 works on Windows 11, I have found - See: Use Google Chrome in Ubuntu on Windows Subsystem Linux and Run Linux GUI apps on the Windows Subsystem for Linux. GUI apps in WSL2 on Windows 10 is also apparently available, but I haven't yet tried it there: see How to install Linux GUI apps on Windows 10. It works because it avoids the apparent issues of networking between Ubuntu on WSL2 and Windows. It's as if you have an ordinary Linux box running ddev and chrome.

Option 2, I have found works both on Windows 11 and Windows 10. Edit the Windows equivalent of the /etc/hosts file, C:\Windows\System32\drivers\etc\hosts - this file is present on both Windows 11 and Windows 10. You'll need to run your text editor as Administrator to edit it and if you use a filter in your text editor's File open dialog, set it to All, to find all files not just .txt files - hosts doesn't have a file extension.

So for you, @hobbsie, the change you'd do in C:\Windows\System32\drivers\etc\hosts would be:

127.0.0.1 junk.ddev.site

and if there is already a line that starts with 127.0.0.1 in hosts comment it out to keep it for future but so that it is not active.

Refs:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文