Reputation: 2090
I'm a newbie on laravel, and running homestead I had one site before added another one did not work. I destroyed homestead and started once again and added two sites in Sites section in homestead.yaml file the bluprint of my homestead.yaml file is below
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/laravel
to: /home/vagrant/laravel
sites:
- map: project1.dev
to: /home/vagrant/laravel/project1/public
- map: project2.dev
to: /home/vagrant/laravel/project2/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
# blackfire:
# - id: foo
# token: bar
# client-id: foo
# client-token: bar
# ports:
# - send: 93000
# to: 9300
# - send: 7777
# to: 777
# protocol: udp
I added those two sites in my /etc/hosts
file as well blueprint is below
#laravel maps
192.168.10.10 project1.dev
192.168.10.10 project2.dev
but when i run project1.dev or project2.dev they both show me the content of project1.dev files
Any Idea?
Upvotes: 3
Views: 3267
Reputation: 57
I had problems trying to provision when I had more than 50 or so sites running under apache - the process aborted at a certain point due to how long it took after each one was added for apache to restart.
My workaround was to do the following:
Make a copy of homestead.yaml
Temporarily remove all the sites in the homestead.yaml file BEFORE the one where the failure occurred.
Create a new folder as root at /etc/apache2/sites-parked and move all the links in /etc/apache2/sites-enabled into it:
sudo mkdir /etc/apache2/sites-parked;
sudo mv /etc/apache2/sites-enabled/* /etc/apache2/sites-parked/;
exit;
Reprovision vagrant again to bring in all the new sites with their SSL certs
Assuming that things worked this time and the provision process completed, go back and move the site linkages you parked earlier back into the right place:
sudo mv /etc/apache2/sites-parked/* /etc/apache2/sites-enabled/;
sudo apache2ctl restart;
I hope this helps someone.
Upvotes: 0
Reputation: 2090
I think I needed to the vagrant provision
command to restart the server and register the changes that I have made
so once you finished with homestead.yaml
and /etc/hosts
file run this
vagrant provision
Upvotes: 4
Reputation: 39
You can't use tabs on the file, use only spaces to indentation and this will solve the problem.
Now, only run
vagrant reload --provision
To reload the configuration file.
Note: If you use vagrant destroy and vagrant up, you lose everything on your VM.
Upvotes: 4
Reputation: 917
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.11"
...
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.11 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.
Of course there is a Homestead.yaml
file inside ~/.homestead
, but vagrant goes for the .yaml
file that is located inside project root first. In my case, the ~/.homestead/Homestead.yaml
file is ignored.
Upvotes: 1