Laravel homestead multiple sites choose which one is locally accesable

笑着哭i 提交于 2019-12-10 23:31:01

问题


I have multiple sites in laravel homestead. Now, I want to access a spezific site via the ip in my local network. But I get allways the site I dont want...

homestead.yaml

sites:
- map: mdb.local
  to: /home/vagrant/code/mdb/public
  type: "apache"

- map: zz.tested
  to: /home/vagrant/code/abc/public
  type: "apache"

- map: 192.168.10.10
  to: /home/vagrant/code/mdb/public

And my hosts

192.168.10.10 mdb.local
192.168.10.10 zz.tested

I can access both on my computer with the domain, however I allways get abc over the ip in the local network. What do I have to change to get mdb on mobile and abc is accessable only on my computer?

I've read this StackOverflow Question but - you can see my implementation of this solution - it doesn't help to solve this problem.


回答1:


Apache always takes the first site alphabetically and returns that as the default host. What you can do is to make a host called 000default or similar, which will then be returned when there's no hostname.




回答2:


You can accomplish this by configuring the second app/site to run on port 81 rather than port 80, and then setting up a port forward to send 8001 or 8100 to 81.

sites:
- map: mdb.local
  to: /home/vagrant/code/mdb/public
  type: "apache"
  port: 81

- map: zz.tested
  to: /home/vagrant/code/abc/public
  type: "apache"

ports:
  - send: 8100
    to: 81

With this, you should be able to access your mdb application via the correct port. From inside Homestead, that would be 81. From outside, that would be 8100. The port is needed regardless of whether you are using the host machine's IP address (e.g. http://192.168.1.5:8100) or a hosts entry (e.g. http://mdb.local:8100).



来源:https://stackoverflow.com/questions/53334226/laravel-homestead-multiple-sites-choose-which-one-is-locally-accesable

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