可以使用PHP Artisan服务在其他设备上访问Localhost

发布于 2025-01-26 03:33:44 字数 138 浏览 1 评论 0原文

最近,我试图使用另一台设备在同一WiFi上访问我的Laravel Web应用程序,并且效果很好(我将IPv4复制到了 - 主机中)。但是,当我在其他WiFi上尝试使用它时,尽管遵循相同的步骤并使用正确的IPv4,但它根本不起作用。请问为什么这是这样,该如何解决?

recently I was trying to access my laravel web app on the same wifi using another device and it works well(I copied the ipv4 into the --host). However, when I tried it on a different wifi, it doesn't work at all despite following the same steps and using the correct ipv4. May I ask why is that so and how do I fix it?

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

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

发布评论

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

评论(2

清风疏影 2025-02-02 03:33:44

在Visual Code或CMD上运行此此操作,您必须在Laravel目录中

php artisan serve --host=0.0.0.0

然后转到CMD并键入以下内容:

ipconfig | findstr IPv4

复制IPv4地址您的设备IP ,然后只是只需将其粘贴到8000端口上的浏览器上,就应该像这个示例一样。 (192.168.100.77:8000

享受开发!

Run this on visual code or CMD, you must be in laravel directory,

php artisan serve --host=0.0.0.0

then just go to cmd and type the following:

ipconfig | findstr IPv4

Copy the IPV4 Address Your device IP, and then just simply paste it on your browser with the 8000 port, it should be like this example. (192.168.100.77:8000)

Enjoy Developing!

太阳哥哥 2025-02-02 03:33:44

如果要从其他设备访问它,则应像这样启用它:

php artisan serve --host=0.0.0.0

它将允许网络中的任何设备访问它,

则可以使用WiFi和以太网访问

如果您在主机中设置WiFi IPv4, 它您与以太网有联系的时间无法正常工作

If you want to access it from another device you should enable it like so :

php artisan serve --host=0.0.0.0

it will allow any device in your network to access it,

and it will work with wifi and with ethernet

If you set your wifi ipv4 in the host but at the same time your are connected with ethernet it won't work

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