Vagrant - Homestead Setup Multiple sites

2019-03-20 12:09发布

问题:

I have mapped the folders etc using the homestead.yaml;

ip: "192.168.10.10"

...

folders:
    - map: /Users/User/Desktop/folder/Homestead/First
      to: /home/vagrant/First

    - map: /Users/User/Desktop/folder/Homestead/Second
      to: /home/vagrant/Second

sites:
    - map: first.dev
      to: /home/vagrant/First/public

    - map: second.dev
      to: /home/vagrant/Second/public

But when i set up the hosts file, etc/hosts with my second.dev to 192.168.10.10 i find that the mapping goes to first.dev, not the mapping that i have set up for second.dev.

How can i go about making the mapping return the correct site?

EDIT: I am using Mac OS X.

回答1:

Using Vagrant commands

Run the command vagrant provision within terminal or your command prompt within the folder where homestead files are located.

Another equivalent command is vagrant up --provision this will provision the vagrant machine as well as run it.

Using Global Homestead

You can use the command homestead provision to re-provision the vagrant machine, regardless of the place you call it from within the terminal.

Alternatively, you can use the serve command to add the information to your Homestead.yaml file for you. Like so;

serve domain.app /home/vagrant/Code/path/to/public/directory

But add this to your hosts file so you can access the your app via domain.app in your browser.