Using vagrant and homestead for multiple sites and per project installation

后端 未结 4 1942
星月不相逢
星月不相逢 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:37

    There are some important steps missing in the accepted answer although it helped me lot. I have added those necessary steps. Thanks @Hieu Le for answer.

    I assume you have correctly installed your fist site as by the instructions of Laravel docs. Now you have another laravel site which you want to shift on vagrant. Follow the following steps.

    1. cd into the directory of new Laravel project which you want to add. I assume you have all laravel files in it and its working using MAMP or any non-vagrant solution.
    2. run vagrant init laravel/homestead. This command will add the necessary VagrantFile in this new project.
    3. open the directory of your first original project file and open its Homestead.yaml file in editor.
    4. Now follow the steps defined by @Hieu Le in accepted answer to modify .yaml file

      folders:
           - map: ~/pj1
             to: /path/to/project1
           - map: ~/pj2
             to: /path/to/project2
      
      sites:
          - map: project1.local
            to: /home/vagrant/pj1/public
          - map: project2.local
            to: /home/vagrant/pj2/public
      

      Edit your hosts file to forward these domain fo localhost

      127.0.0.1 project1.local
      127.0.0.1 project2.local
      
    5. On terminal cd into your first original original project directory.
    6. Run command vagrant reload --provision. This will reload the vagrant machine so that the changes which we made in .yaml file come in effect. You database of original project will remain intact.
    7. Run vagrant ssh
    8. Run ls and make sure you can see the folder of your new project. If its there you have configured your new site correctly.
    9. Hit the url of new site with addition of http:// and your are DONE.

提交回复
热议问题