从外部设备本地访问Laravel 5应用 [英] Access to Laravel 5 app locally from an external device

查看:54
本文介绍了从外部设备本地访问Laravel 5应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在网络上寻找解决方案,但是我还没有找到解决方案. 我需要从iPhone上访问Laravel 5应用程序,但是我正在开发中,所以我不想在网络服务器上发布我的应用程序.

I've looked for a solution in the web, but I've not found a solution yet. I need to access to my Laravel 5 app from my iPhone, but I'm in develop, so I don't want to publish my app on a web server.

如果您有链接,请确保它可以工作,这对我来说是完美的.

If you have a link to follow, that you assure it works, It's perfect for me.

谢谢!

推荐答案

如果您出于某些特殊原因不打算使用Apache或nginx,并且这仅出于开发目的,则可以提供服务使用PHP内置服务器和artisan的应用程序.到目前为止,这是最简单的设置,只需要您在Laravel应用程序目录中运行一个命令即可:

If you're not bound to using Apache or nginx for some special reason and this is for development purposes only, you could serve the application using the PHP built-in server and artisan. It's by far the easiest thing to setup, and will only require you to run one command in the Laravel application directory:

php artisan serve --host 0.0.0.0

它将监听的默认端口为8000,以避免发生任何冲突,因此您现在可以通过计算机的IP地址从手机访问应用程序:

The default port it will be listening to will be 8000 to avoid any conflicts, so you can now access the application from your phone via the IP address of your computer:

http://192.168.1.101:8000

如果您想监听其他端口(例如,默认的HTTP端口80),则可以将其作为参数传递,只需确保该端口上没有其他服务器在运行.因此,如果您改为运行此代码:

If you want to listen to another port (for example the default HTTP port of 80) you can pass that as a parameter, just make sure no other server is running on that port. So if you run this instead:

php artisan serve --host 0.0.0.0 --port 80

您现在只需使用IP地址即可访问您的应用程序:

You can now access your application with just the IP address:

http://192.168.1.101

这篇关于从外部设备本地访问Laravel 5应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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