Homestead Multiple Sites

Written by Rich Banks on 22nd Jan, 2016

Laravel

I have been reading a lot of forum posts recently about using multiple sites on Homestead. Most of the solutions I have read seem to over complicate things, so I thought I would write this post to show how easy it can be. The process below is non-destructive so you will not lose any data stored on your current homestead set up.

Firstly you need to change your hosts file. I am on Mac so I can simply open Finder. Select 'Go' from the top menu and click 'Go To Folder'. In the search field that shows enter '/private/etc/hosts' and click Go. Now locate the 'Hosts' file and open in a text editor. On a new line enter:

192.168.10.10   newsite.dev

The IP address will be the IP address you set up in your Homestead.yaml file.

The process on Windows will be very similar. Your hosts file should be located at 'C:\Windows\System32\drivers\etc'.

Now in the terminal run the below command to open your Homestead.yaml file.

homestead edit

Under folder add:

- map: /path/to/app/directory
    to: /home/vagrant/newsite

Under sites add:

- map: newsite.dev
    to: /home/vagrant/newsite

Save the file and close.

From the terminal, ssh into your homestead machine.

homestead ssh

Run.

serve newsite.dev /home/vagrant/newsite

Close your ssh connection.

exit

Stop your homestead server and then start it again.

homestead halt
homestead up

You can now use newsite.dev in the browser and view your new application.

  • Mandila

    • 4 years ago

    Sustain the spectacular job !! Lovin it!