简体   繁体   中英

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:

在此输入图像描述

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

更改配置中的某些内容时的黄金法则是使用provision选项重新加载vagrant机器,因此请尝试运行:

vagrant reload --provision

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

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

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"

For windows use the backslash \\ when mapping to a specific folder Try this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM