Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

freekmurze's avatar

Create multiple sites on Homestead 2.0

So Homestead 2.0 is up and running. I'm adding a second site using "homestead edit".

Now I want to make the second site active. I could go to ~/.composer/vendor/laravel/homestead and run "vagrant provision" there.

Is there an easier way to do this?

0 likes
15 replies
abhimanyusharma003's avatar

You can do this, after this restart vagrant to load new config file

folders:
    - map: D:/www/codes/first
      to: /home/vagrant/first
    - map: D:/www/codes/second
      to: /home/vagrant/second 

sites:
    - map: first.dev
      to: /home/vagrant/first/public
    - map: second.dev
      to: /home/vagrant/second/public
3 likes
abhimanyusharma003's avatar

vagrant reload

If this doesn't work out

Do vagrant destroy and then vagrant up

Or

  • open virtual box
  • stop and delete current image
  • again do vagrant up

( I know it will take some time but yes it this always works for me, you might loose previously stored database on that image )

noeldiaz's avatar

Taylor mentioned on twitter that he intends to add the "provision" flag to Homestead 2.0. For now destroying and creating a new one are your best bets, or going in to the dir and doing what you mention directly with Vagrant.

1 like
Ionut's avatar

What happened to the old "serve myawesomesite.app ~/Code/myawesomesite/public" script?

If you continuously destroy your vm you're gonna lose data every time, like databases and stuff. I prefer the old way. I create manually what serve.sh does automatically... a site under /etc/nginx/sites-available/myawesomesite.app and symlink it to sites-enabled.

Did it get removed?

IsraelOrtuno's avatar
Level 7

Use

homestead up --provision

Take into account that you will miss all your databases data when provisioning in homestead 2.0

5 likes
Jawad's avatar

This will work you don't need to loose your db.
EPOCLAB:~ Dev$ homestead halt

EPOCLAB:~ Dev$ homestead up --provision

2 likes
London_S5's avatar

I had this working at some stage, then gave up the whole project and now I am trying again to get working. For some reason the second.app gives an error: (no input file specified) even though when I ssh into the box and go to the home/vagrant/code/second folder I do find files in there, any ideas? thanks

London_S5's avatar

Multi host homestead installation, hi all, I have this working before but for some reason it stopped now and I have tried many options but still can't get it to work.

I have put the Yaml file as follows: (the relevant part) folders: - map: F:\Homestead\Projects\first to: /home/vagrant/Code/first - map: F:\Homestead\Projects\second to: /home/vagrant/Code/second - map: F:\Homestead\Projects\off to: /home/vagrant/Code/off

sites: - map: first.app to: /home/vagrant/Code/first/public - map: second.app to: /home/vagrant/Code/second/public - map: off.app to: /home/vagrant/Code/off/public

then I put it in my hosts file as such: 192.168.10.10 first.app 192.168.10.10 second.app 192.168.10.10 off.app

Now when I boot up, I get first to work, but for second and off.app I get (no input file specied) error.

Any suggestions? thanks

1 like
montie's avatar

@London_S5 , be careful with the tabulation in YAML. I had the same problems in editors, like notepad++, gedit and sublime text 2. This may be your problem. Check out the tabs in compartiments, which start with "-" in different editors to be sure, you are using correct syntax. For example, notepad++ colorizes in red wrong syntax in YAML, but at the same time it sometimes doesn't reflect correct syntax, as it is. For many days I did not understand, with this editor, what's the problem with YAML - vagrant showed me the same error as you have, bur in notepad++ all the tabs and other syntax seemed OK. Then I checked out that file in PhpStorm and there wrong tabulation was detected correctly.

postitief's avatar

I'm not sure which version om Homestead I'm running, but I can run as much sites I want, without changing anything to the Homestead.yaml file. I don't change any configuration file and don't need to reboot / provision homestead vagrant.

In the Homestead.yaml file, I added this mapping:

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

So every folder in my local Code directory is mapped to homestead. If I want to add a site I do: Add a new Laravel project to my Code directory, for example: ~/Code/newsite I start up homestead, ssh into it and run this command.

serve www.newsite.dev /home/vagrant/Code/newsite/public

Now add this domain to your host file, on OS X, use this command:

sudo nano /private/etc/hosts

Add the new domain:

192.168.10.10   www.newsite.dev

Enter www.newsite.dev in you browser, you should now get your newly installed website.

7 likes
sandipme99's avatar

Hope this can be helpful as i have been doing this and it works perfect for me;


ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
  - ~/.ssh/id_rsa

folders:
 - map: C:\Code
     to: /home/vagrant/Code

sites:
    - map: ticket.app
    to: /home/vagrant/Code/ticket/public

 - map: tender.app
    to: /home/vagrant/Code/tender

    - map: test.app
    to: /home/vagrant/Code/test

databases:
 - homestead    

And My Host file looks as below.


192.168.10.10  ticket.app
192.168.10.10  tender.app
192.168.10.10  test.app
Under my Code Folder I have 3 folder name below: 1. ticket (Using laravel framework) 2. tender (my php project) 3. test (my php project)
1 like
jonathanbriehl's avatar

I know this is an old thread, but wanted to see if anyone had any ideas about something. I had been running a setup like what abhimanyusharma003 suggested in the first reply. The last time I ran Vagrant, everything worked fine. Today when I started Vagrant both sites seem to be pointing to the same project. Meaning, no matter which URL I hit, the same project loads. I did have the change my domain from a '.dev' to a '.local' to get around the HTTPS redirects that were happening. Hoping someone else has an idea or has run into the same problem and has a work-around. Any help is appreciated.

Please or to participate in this conversation.