问题描述
我已经在网上寻找解决方案,但我还没有找到解决方案.我需要从我的 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
如果您想侦听另一个端口(例如 80
的默认 HTTP 端口),您可以将其作为参数传递,只需确保该端口上没有其他服务器正在运行.所以如果你运行这个:
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 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!