How to troubleshoot and enable folder synchronisation in Laravel Homestead? - laravel

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.

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 :)

Homestead / Vagrant not provisioning or serving additional sites

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!

Homestead Running, SSH Works, But HTTP Connections Time Out

I'm having an issue with a homestead configuration that was previously running correctly. After reading some bad advice online regarding a separate issue, I accidentally wiped out my homestead.yaml by re-running init.bat, and have recreated the homestead config from memory the best I can. Most everything seems to be working - I can start the box successfully, and I can connect via SSH. My web root is mapped to the box correctly, as I can see all my project files on the box where I chose to map them. When I try to access the site via http (through the name I've mapped it to), I get a timeout. I've ensured that my hosts file has the update from myapp.app to 192.168.10.10, the same IP as in my homestead.yaml file. I will note, however, that when I ping 192.168.10.10 from the terminal, I also get a timeout.
Here's my Homestead.yaml:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: C:/Users/MyUsername/.ssh/id_rsa.pub
keys:
- C:/Users/MyUsername/.ssh/id_rsa
folders:
- map: C:/Users/MyUsername/Projects/myapp_laravel
to: /home/vagrant/code/myapp
sites:
- map: myapp.app
to: /home/vagrant/code/myapp/public
databases:
- homestead
Here's my hosts file:
192.168.10.10 myapp.app
I'll also note that I can successfully access my app via: http://localhost:8000/
I have also restarted my host machine since updating the hosts file, and reprovisioned the box.
Restarting the host machine again solved this for me.

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.

No laravel sync folders in homestead vagrant on windows

i installed vagrant lately on my windows 7 machine, i successfully runned the virtual machine because i can ssh to it but no synchronization between my local project and the homestead.
my yaml file is like :
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: /Users/User/Homestead/projects
to: /home/vagrant/sites
sites:
- map: laravel.dev
to: /home/vagrant/sites/laravel/public
hhvm: true
databases:
- homestead
variables:
- key: APP_ENV
value: local
My laravel project is inside projects folder in my local homestead directory, but it seems that the sites folder that links to it is not synced with it !!
i'm not good at unix command line but is it weird that ls -la command work but ls alone don't seem to work as i saw if tutorials ?
update :
After changing the hosts file setup for : 127.0.0.1 laravel.dev to 192.168.10.10 laravel.dev the site was accessible in my browser, but the problem of no syncronization still happening (i had to install a new laravel in vangrant) i want to deplay my project from wamp to projects folder and be syncronized with "sites" in homestead
Edit your Homestead.yaml
In the line
---
folders:
- map: E:/projects //your projects folder here
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
Now if you are using Windows, open notepad as administrator and your hosts
System32/drivers/etc/hosts
192.168.10.10 laravel5angularapp.dev
192.168.10.10 angular2laravel.dev
192.168.10.10 laravel5-angular2.dev
192.168.10.10 yourproject.dev
Now access your homestead
homestead up
homestead ssh
Inside homestead
cd Code
ls -a
All your projects should appear here, then
cd ~
then
serve yourproject.dev /home/vagrant/Code/yourlaravelprojectname/public/
Then
sudo service nginx restart
Or
homestead reload
Your project should be running in
http://yourproject.dev
I've tried many things but none of them worked. Finally i've changed map folder to the full path version and then run the vagrant reload command and it was ok.
Homestead.yaml
folders:
- map: C:/Users/username/Code
to: /home/vagrant/Code.
vagrant reload
You can use ~/Homestead/projects in windows is the same the C:\Users\your_user\your_folders

Resources