laravel5 本地访问VM虚拟机

使用VM虚拟机,composer创建完laravel项目,启动

 # php artisan serve 

运行结果是Laravel development server started: http://127.0.0.1:8000

要求你通过http://127.0.0.1:8000去访问,可是我们访问虚拟机是需要通过ip去访问的,网上搜了也搜不到怎么设置ip地址,最后搜到了用另外一种方法启动服务:
切换到项目根目录下:

# php -S 虚拟机ip:8000 ./server.php。

这样就可以通过ip+8000端口去访问啦。
后台运行

# nohup php -S 虚拟机ip:8000 ./server.php &

Ctrl+C

详细看这里:https://segmentfault.com/a/1190000013025428

猜你喜欢

转载自blog.csdn.net/weikaixxxxxx/article/details/84031706
今日推荐