Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Homestead folders mapping not working correctly

I have installed homestead following the steps described in the Laravel site. The installation is completed successfully.

I have configured the 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: D:/Code/Homestead/Projects/RestaurantManager
      to: /home/vagrant/RestaurantManager

sites:
    - map: laravel.app
      to: /home/vagrant/RestaurantManager/public

databases:
    - homestead

variables:
    - key: 'APP_ENV'
      value: 'local'
    - key: 'APP_DEBUG'
      value: 'true'

Edit the hosts file:

127.0.0.1   laravel.app
192.168.10.10 laravel.app

I can run vagrant up and ssh into the virtual machine.

The problem is that the folder mapping does not work. The mapping always uses the same path (D:/Code/Homestead), despite me giving a different one. You can see it here:

enter image description here

So when I try to access the app locally I get "page not available".

like image 276
Florian Shena Avatar asked Nov 22 '15 18:11

Florian Shena


4 Answers

The golden rule when you change something in the configuration is to reload the vagrant machine with the provision option, so try running :

vagrant reload --provision
like image 89
teeyo Avatar answered Sep 28 '22 00:09

teeyo


The Homestead.yaml file should have:

folders:
    - map: D:/Code/Homestead/Projects # Note 1
      to: /home/vagrant/Code # Note 2

sites:
    - map: laravel.app
      to: /home/vagrant/Code/RestaurantManager/public
  1. Should match your OS file structure
  2. The file structure of Homestead, which you should not change.

Your hosts file also needs to be updated to remove the reference to 127.0.0.1 (which is your localhost):

192.168.10.10 laravel.app
like image 41
Kirk Beard Avatar answered Sep 27 '22 23:09

Kirk Beard


I have a similar problem due to the vagrant-hostsupdater. Just uninstall the plugin using

vagrant plugin uninstall vagrant-hostsupdater

and then provision the machine again

vagrant reload --provision
like image 20
Jesús Amieiro Avatar answered Sep 27 '22 22:09

Jesús Amieiro


First of all, you need to know that Vagrant automatically configures the current directory of the Vagrantfile from the host machine as a shared folder to the /vagrant directory inside the VM.

To disable this default behaviour, add this line in your Vagrantfile:

config.vm.synced_folder ".", "/vagrant", disabled: true

Secondly, you can write the windows file path by escaping the \ characters like so:

folders:
    - map: D:\\Code\\Homestead\\Projects\\RestaurantManager
      to: /home/vagrant/RestaurantManager

⚠Important: After you've done this, run:

vagrant reload --provision

Alternatively, you can delete the whole folders section in your Homestead.yaml and specify the shared folders mapping directly in Vagrantfile like so:

config.vm.synced_folder ".", "/home/vagrant/RestaurantManager"
like image 44
Marius Crisan Avatar answered Sep 28 '22 00:09

Marius Crisan