Homestead / Vagrant not provisioning or serving additional sites - vagrant

I'm attempting to run multiple sites in my Homestead box, wordpress.dev and responsible.dev. However, upon navigating to http://responsible.dev it displays the content from wordpress.dev.
I've set up the sites in my Homestead.yaml and hosts file, and ran various attempts of:
vagrant provision
vagrant provision <vm_id>
vagrant reload --provision
vagrant destroy followed by vagrant up
vagrant ssh followed by serve responsible.dev /home/vagrant/Code/responsible
but nothing seems to be working.
The output of vagrant up / vagrant provision shows it creating the wordpress.dev site, but not provision.dev
but I'm not sure what I am doing wrong for it to be skipping over.
My Homestead.yaml file:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Code
sites:
- map: wordpress.dev
to: /home/vagrant/Code/wordpress
- map: responsible.dev
to: /home/vagrant/Code/responsible
databases:
- homestead
and hosts file:
192.168.10.10 wordpress.dev
192.168.10.10 responsible.dev
I assume it is something basic and obvious that I am over-looking, but I can't for the life of me see it.
Thanks in advance!

Related

Laravel project wont serve to given ip via Homestead

I am having trouble setting up my laravel project on my mac. I have (As far as I can tell) set up the homestead.yaml config correctly within my Homestead directory:
---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Documents/GitHub/project-darwin
to: /home/vagrant/code
sites:
- map: homestead.test
to: /home/vagrant/code/public
php: "7.2"
databases:
- homestead
After I have used vagrant up, on using vagrant ssh I can see my project inside of vagrant/code/project-darwin.
My hosts file is as follows:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.10.10 homestead.test
Which looks correct as is no different to what I normally do when running other laravel projects on virtualbox, however on going to my url, I get a 500 error and the same applies if I go directly to the ip (198.168.10.10).
A further thing I find suspicious is the following. When I use vagrant up, this is part of what shows in my terminal:
homestead-7: Waiting for machine to boot. This may take a few minutes...
homestead-7: SSH address: 127.0.0.1:2222
homestead-7: SSH username: vagrant
Should this ip be the same as the ip I supplied? Anyway, I have run out of ideas as to how to go about fixing this, any suggestions?
So it turns out my mac had auto selected . hyperv as my provider when I ran vagrant box add laravel/homestead, oh well..
In your Homestead.yaml config file you are doing the following:
Making a shared folder mapping project-darwin to /home/vagrant/code
folders:
- map: ~/Documents/GitHub/project-darwin
to: /home/vagrant/code
But under sites you are mapping the folder /home/vagrant/code/public to homestead.test, meaning when you are requesting homestead.test or the IP of your Vagrant Box, you are not calling upon project-darwin but rather the "empty" public folder.
sites:
- map: homestead.test
to: /home/vagrant/code/public
I would recommend either moving your code to the public folder or mapping sites to your desired destination.
Hope this helps :)

The web.app page isn’t working

When i try to open web.app it doesnt work. But vagrant up running successfully. Hier is my Homestead.yarn file
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/www/
to: /home/vagrant/www
sites:
- map: web.app
to: /home/vagrant/www/web
databases:
- homestead
I'm using Mac OS.
laravel box : laravel/homestead (virtualbox, 1.1.0)
in hosts 127.0.0.1 web.app (192.168.10.10 and 127.0.0.1 both doesn't work)
vagrant and homestead are up to date. Any idea?
web.app:8000 doesn't work else
First on your homestead.yaml file, make the following changes
folders:
- map: ~/www/web
to: /home/vagrant/www/web
sites:
- map: web.app
to: /home/vagrant/www/web/public
Then go to your Homestead folder and do
vagrant reload --provision
After reloading do
vagrant up
Then edit the /etc/hosts file and add the following line
192.168.10.10 web.app
Now you should get laravel homepage when you hit web.app on your browser
I don't know why but my hosts file is ignored. Therefore i used just 192.168.10.10 instead web.app after 10 hour i fixed the problem. just deleted hosts file and created it again.

vagrant homestead directory missing

when I run command ls it doesn't show any file.
My homestead.yaml file:
which directory should i look in to check.
There's seems to be some issues with homestead lately for windows folk.
to make sure you can access your files in the VM just add the following in your Vagrantfile
config.vm.synced_folder "C:/Users/<User>/projects", "/home/vagrant/Code"
Try to provision the Vagrant VM
vagrant reload --provision
I paste my Homestead.yaml file. You are in Windows, so try to put your complete local folder (C:\Users\my_user\development in my machine) and provision the machine another time
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: C:\Users\my_user\development
to: /home/vagrant/Code
sites:
- map: my_site.app
to: /home/vagrant/Code/web/my_site/public
databases:
- my_database

How to troubleshoot and enable folder synchronisation in Laravel Homestead?

I have followed instructions (https://laravel.com/docs/5.2/homestead) to set up laravel running in a Vagrant/Homestead box.
In the end, I should be able to the website from virtual machine by accessing homestead.app in browser on my host machine.
I´ve tried accessing in different ways, with and without specifying port 8000:
http://homestead.app - connection timeout
http://192.168.10.10 - connection timeout
http://localhost - connection timeout
http://127.0.0.1 - connection refused
After troubleshooting I have found that files are not synced to the virtual machine.
E:\homestead_local\Laravel\public\ contains index.php which I try to access. It is not synced to the VM.
I can´t find any error logs on server.
Also, on VM home/vagrant folder was empty after I did everything from instructions. I´m not sure if that was supposed to happen.
Instructions of what I did, keeping them short:
Installed Virtualbox 4.2 and Vagrant 1.8.1
Dowloaded vagrant box:
vagrant box add laravel/homestead
Installed Homestead 0.4.1
git clone https://github.com/laravel/homestead.git Homestead
Initialized homestead:
bash init.sh
Edited homestead.yaml file
Edited hosts file
Hosts file:
192.168.10.10 homestead.app
127.0.0.1 homestead.app
homestead.yaml file:
ip: "192.168.10.10"
memory: 768
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: E:\HSprojects
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
Questions
After running "vagrant up" my CMD shows this:
....
default: Mounting shared folders...
default: /vagrant => E:/Homestead
Why is it showing E:/Homestead and not E:/HSProjects?
Is sharing between folders bidirectional? I can't find a clear answer on this, but I assume they are.

My Homestead reset when i restart my machine

I'm facing a problem that everytime i restart my machine homestead reset, i mean when i ssh to my box, i can't find the directories in the development directory
I mean that i find the directories on my machine but when i ssh to homestead i can't find them
i tried to run homestead provision but nothing changed, still can link between my machine and the virtual box
you see below that i have laravel directory linked to my current box code\laravel
My setup like that
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/code
to: /home/vagrant/code
sites:
- map: laravel.app
to: /home/vagrant/code/laravel/public
databases:
- homestead
variables:
- key: APP_ENV
value: local
Sounds annoying. Have you tried using vagrant reload instead?
In case you know when you're going to shut down your computer (not when low battery is forcing a shutdown) you can save your vagrant box's state by doing vagrant suspend and after boot: vagrant resume.
Hope this works for you.

Resources