[英]Laravel Homestead folders mapping not working correctly
I have installed homestead following the steps described in the Laravel site . 我按照Laravel 网站中描述的步骤安装了宅基地。 The installation is completed successfully.
安装成功完成。
I have configured the Homestead.yaml file: 我已经配置了Homestead.yaml文件:
---
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: 编辑hosts文件:
127.0.0.1 laravel.app
192.168.10.10 laravel.app
I can run vagrant up and ssh into the virtual machine. 我可以运行vagrant并将ssh运行到虚拟机中。
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.
尽管我给出了不同的路径,但映射总是使用相同的路径(D:/ Code / Homestead)。 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: Homestead.yaml
文件应具有:
folders:
- map: D:/Code/Homestead/Projects # Note 1
to: /home/vagrant/Code # Note 2
sites:
- map: laravel.app
to: /home/vagrant/Code/RestaurantManager/public
Your hosts
file also needs to be updated to remove the reference to 127.0.0.1
(which is your localhost): 您的
hosts
文件也需要更新以删除对127.0.0.1
(这是您的localhost)的引用:
192.168.10.10 laravel.app
I have a similar problem due to the vagrant-hostsupdater . 由于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. 首先,您需要知道Vagrant会自动将
Vagrantfile
的当前目录从主机配置为VM内/vagrant
Vagrantfile
目录的共享文件夹。
To disable this default behaviour, add this line in your Vagrantfile
: 要禁用此默认行为,请在
Vagrantfile
添加以下行:
config.vm.synced_folder ".", "/vagrant", disabled: true
Secondly, you can write the windows file path by escaping the \\
characters like so: 其次,您可以通过转义
\\
字符来编写Windows文件路径,如下所示:
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: 或者,您可以删除
Homestead.yaml
的整个folders
部分,并直接在Vagrantfile
指定共享文件夹映射, Vagrantfile
所示:
config.vm.synced_folder ".", "/home/vagrant/RestaurantManager"
For windows use the backslash \\
when mapping to a specific folder Try this: 对于Windows,在映射到特定文件夹时使用反斜杠
\\
试试这个:
folders:
- map: D:\Code\Homestead\Projects\RestaurantManager
to: /home/vagrant/RestaurantManager
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.