Using vagrant and homestead for multiple sites and per project installation

后端 未结 4 1953
星月不相逢
星月不相逢 2020-12-23 12:04

I have been using XAMPP for quite a time, and after discovering Laravel and finding out, that I quite like it, I also wanted to use Homestead. The problem I\'m having is, th

4条回答
  •  鱼传尺愫
    2020-12-23 12:28

    Like how here says, you can install Homestead directly into your project, require it using this composer require laravel/homestead --dev at root directory of each project you have. Now by make command you can generate Vagrantfile and Homestead.yaml file into your project's root directory.

    • Mac/Linux:

      php vendor/bin/homestead make
      
    • Windows:

      vendor\bin\homestead make
      

    On each project root you will have a Homestead.yaml file to edit:

    • Project-A

      ip: "192.168.10.10"
      ...
      folders:
          - map: "~/Code/projecta"
            to: "/home/vagrant/projecta"
      sites:
          - map: project.a
            to: "/home/vagrant/projecta/public"
      
    • Project-B

      ip: "192.168.10.10"
      ...
      folders:
          - map: "~/Code/projectb"
            to: "/home/vagrant/projectb"
      sites:
          - map: project.b
            to: "/home/vagrant/projectb/public"
      

    Add this to /etc/hosts:

        192.168.10.10 project.a
        192.168.10.10 project.b
    

    Then you have to cd to each project's root and vagrant up. Now if you vagrant ssh from each project, you will have that project in your VM environment.

提交回复
热议问题