无法连接到Virtual Box设备中的Laravel服务器 [英] Cannot connect to Laravel server in Virtual Box appliance

查看:78
本文介绍了无法连接到Virtual Box设备中的Laravel服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Laravel实现我的第一个Rest API.

I am trying to implement my first Rest API using Laravel.

我正在Windows主机上的Virtual Box计算机上运行Debian.VM的网卡配置为仅主机适配器".

I am running Debian on a Virtual Box machine on a Windows host. The network card of the VM is configured to "Host-only adapter".

我能够使用 http://ip-of-the-vm/phpmyadmin 到达计算机上的phpmyadmin实例.但是,当我尝试在 http://ip-of-the-vm:8000 上访问Laravel设备时,它不起作用.我认为端口可能是个问题.

I am able to reach the phpmyadmin instance on the machine using http://ip-of-the-vm/phpmyadmin. But when I try to reach the Laravel appliance on http://ip-of-the-vm:8000 it does not work. I think the port could be the problem.

有人对如何解决这个问题有建议吗?

Does anybody have a suggestion for how to solve this?

推荐答案

问题是laravel仅可通过本地主机访问.您必须使用以下命令启动服务器 php artisan serve --host 0.0.0.0 其中,应将 0.0.0.0 替换为服务器的ip.如果需要,您可以选择定义一个端口,方法是使用例如, php artisan服务--host 0.0.0.0-端口80 .

The problem was that laravel was only reachable over localhost. You have to start the server using php artisan serve --host 0.0.0.0 where 0.0.0.0 should be replaced with the ip of the server. You can optionally define a port if you want by using php artisan serve --host 0.0.0.0 --port 80 for example.

这篇关于无法连接到Virtual Box设备中的Laravel服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆