How to access Laravel Homestead on other devices?

元气小坏坏 提交于 2019-12-01 22:29:27
totymedli

tl;dr

You have to add a row for each site in your host file on the remote machine (just like in the server where Homestead is running) but with the server's IP adress. Then just type sitename.local:8000.

Example

In your case the server's IP is 192.168.0.11. Within this server, Homestead serves requests on 192.168.10.10. So in the host file of the server you have these lines:

192.168.10.10   site1.com
192.168.10.10   site2.com

You have to copy these rows to the remote PC's host file and then replace the IP address with the server's IP: 192.168.0.11.

192.168.0.11   site1.com
192.168.0.11   site2.com

Depending on your OS you may have to restart the PC or the DNS service. After that, you can access the sites from the remote PC in these addresses:

site1.com:8000
site2.com:8000

Note

Keep in mind that editing (writing) the hosts file requires superuser/administrator permissions. This is easy to solve in a PC, if you have access to the administrator account, but can be complicated on a mobile device. For Android check out these questions:

I believe this is the right answer acess homestead from external

all you need to just add default server on your nginx.conf

listen 80 default_server;

You can use http://xip.io/ to setup a magic domain name and you can use these domains to access virtual hosts on your development web server from devices on your local network.

Installation is also easy too https://github.com/basecamp/xip-pdns

If you are using vagrant you can also use vagrant share.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!