Musterknabe Musterknabe - 5 months ago 91x
PHP Question

Using vagrant and homestead for multiple sites and per project installation

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, that I can't seem to be able to run multiple sites.

I have tried various things, but the main problem currently is, that one project works, while all the others are getting a connection timeout, when trying to access their webpage.

These are the steps I've taken to use Homestead

  1. Installing VirtualBox

  2. Installing Vagrant

  3. Adding homestead with
    vagrant box add laravel/homestead

  4. Clonging the repository
    git clone Homestead

  5. Create Homestead.yaml file in the
    directory with the

  6. Create a new project
    laravel new projectA

  7. Require homestead
    composer require laravel/homestead

  8. Generate Vagrantfile
    php vendor/bin/homestead make

  9. Modify the Homestead.yaml to have an IP that ends with 10

  10. Create another project
    laravel new projectB

  11. Require homestead
    composer require laravel/homestead

  12. Generate Vagrantfile
    php vendor/bin/homestead make

  13. Modify the Homestead.yaml to have an IP that ends with 11

  14. Adding those two sites to the hosts file
    sudo nano /etc/hosts

  15. Starting vagrant from one of the two directories
    vagrant up

Now, I'm having the problem, that only one of the projects is reachable. It's always the one from where I called
vagrant up
. So if I call
vagrant up
from Project A I can access
times out. The same the other way around, sadly.

This is my
vagrant global-status

id name provider state directory
fc6fadb default virtualbox running /Users/mknb/work/projectA

I thought I would just do another
vagrant up
from the
directory but that doesn't work of course.

I don't want to use the global Homestead, because Laravel said, that it is possible to have a
per project
installation, so how do I achieve it? Do you need more information?

I didn't modify the
except of the IP and the domainname

It seems like a global installation is fairly easy with Homestead, since I would just have to add more sites to the Homestead.yaml, but as I said I'd like to have a per project installation. Can anybody help?

Starting vagrant from the Homestead directory doesn't work of course.


By using Homestead in your way, you create a virtual machine for each projects. Therefore, the VirtualBox cannot forward the HTTP request from your host machine for all of virtual machine. You can only run one machine (so, one project) each time.

To run multiple projects with Homestead, you can do as follow:

  • Clone Homestead git clone Homestead
  • Inside the Homestead folder, run bash

Edit the folders property of ~/.homestead/Homestead.yaml to share your code of both projects with VM:

    - map: ~/pj1
      to: /path/to/project1
    - map: ~/pj2
      to: /path/to/project2

Edit the sites property of ~/.homestead/Homestead.yaml to make Nginx enable the domain of both site:

    - 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 project1.local project2.local
  • Run vagrant up at the folder that you cloned the Homestead code inside it (which contains the file).

Now, you can run as many project as you want with just one Homestead virtual machine.