laravel Homestead 2.0 多个站点,都链接到同一个url

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27207150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:29:29  来源:igfitidea点击:

Homestead 2.0 multiple sites, all link to the same url

laravelhosts-file

提问by bobbybouwmann

Hee guys, little question: So i have setup the Homestead 2.0 and everything is working fine. I wanted to add another project in the same code directory but link it to another url. So i added it in the sites list but when i visited laravel.app it all works fine, but when I visit larabook.app it shows me the laravel.app page! Both urls are linked to 192.168.10.10 in my /etc/hosts file.

嘿伙计们,小问题:所以我已经设置了 Homestead 2.0,一切正常。我想在同一代码目录中添加另一个项目,但将其链接到另一个 url。所以我将它添加到站点列表中,但是当我访问 laravel.app 时它一切正常,但是当我访问 larabook.app 时它向我显示了 laravel.app 页面!两个 url 都链接到我的 /etc/hosts 文件中的 192.168.10.10。

I have tried restarting my mac and restarting the vm but nothing is working :'(

我试过重新启动我的 mac 并重新启动虚拟机,但没有任何效果:'(

/etc/hosts

/etc/hosts

192.168.10.10 laravel.app
192.168.10.10 larabook.app

Homestead.yaml

宅基地.yaml

folders:
    - map: ~/Code
      to: /home/vagrant/Code

sites:
    - map: laravel.app
      to: /home/vagrant/Code/Laravel/public
    - map: larabook.app
      to: /home/vagrant/Code/Larabook/public

databases:
    - homestead
    - larabook

回答by vic

Assuming your Homestead.yaml file above

假设上面的 Homestead.yaml 文件

type in:

输入:

$ vagrant global-status

will display something like;

会显示类似的东西;

id    name      provider   state   directory    
--------------------------------------------    
77c5c30  default   virtualbox running et....    

type in:

输入:

$ vagrant provision 77c5c30

Of course this assumes you only have 1 VM, if you have others then read the instruction when you run vagrant provision

当然,这假设您只有 1 个虚拟机,如果您有其他虚拟机,请在运行 vagrant provision 时阅读说明

回答by vukan

This works for me, and didn't lose the database:

这对我有用,并且没有丢失数据库:

$ homestead halt
$ homestead up --provision

回答by Davies Wabuluka

Try this

尝试这个

folders:
    - map: ~/Code/Laravel
      to: /home/vagrant/Code/Laravel

    - map: ~/Code/Larabook
      to: /home/vagrant/Code/Larabook

sites:
    - map: laravel.app
      to: /home/vagrant/Code/Laravel/public
    - map: larabook.app
      to: /home/vagrant/Code/Larabook/public

databases:
    - homestead
    - larabook

Note: look at the changes i have made to the folders section. find out more from https://www.easylaravelbook.com/blog/configuring-multiple-laravel-homestead-sites-and-databases/#top

注意:查看我对文件夹部分所做的更改。从https://www.easylaravelbook.com/blog/configuring-multiple-laravel-homestead-sites-and-databases/#top了解更多信息

after run
    $ homestead halt
    $ homestead up --provision