Homestead 2.0、Vagrant和VirtualBox运行比MAMP慢很多

3

我刚刚在OSX 10.10(Yosemite)上的VirtualBox上为Laravel 5设置了Homestead 2.0 Vagrant服务器,但它比MAMP运行得慢得多。

我真的想使用Homestead,但每次加载页面都需要1-3秒的延迟,这变得非常令人恼火,而MAMP的每个加载请求都是瞬间完成的。

我的设置有问题吗?

Homestead.yaml:

---
ip: "192.168.10.10"
memory: 2048
cpus: 2

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: /Users/jackbarham/Code
      to: /home/vagrant/Code

sites:
    - map: tasks.mac
      to: /home/vagrant/Code/tasks/public

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

主机:

##
# 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 tasks.mac

127.0.0.1   tasks-mamp.mac  # MAMP PRO - Do NOT remove this entry!

如果你在Windows上使用,以下是如何加速的方法:https://dev59.com/8VUL5IYBdhLWcg3wQGHd - Yevgeniy Afanasyev
2个回答

2
我在reddit/r/laravel上问了同样的问题,并得到了答案:
  1. 在以下路径中找到homestead.rb文件:/Users/username/.composer/vendor/laravel/homestead/scripts

  2. 关闭虚拟机(homestead halt)

  3. 打开homestead.rb文件,在第49行下面的“# Register All Of The Configured Shared Folders”下更改:

从:

settings["folders"].each do |folder|
    config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil
end

to:

settings["folders"].each do |folder|
    config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, :nfs => true
end
config.vm.network "private_network", type: "dhcp" 

启动(或升级)Homestead,这应该会加速事情的进展。

1
另外,根据同一篇Reddit帖子的说法,您可以在每个“文件夹”映射中添加“type:nfs”。 - alexw

0
在我的情况下,使用Windows作为HOST是一样的,因为VirtualBox使用vboxsf作为文件系统来挂载主机到客户机的文件,我不知道为什么,但它太慢了。
在GUEST(Ubuntu 16.04)上,我将工作文件夹作为网络文件夹使用CIFS进行挂载,运行速度更快。
在客户端上,我使用这个:https://wiki.ubuntu.com/MountWindowsSharesPermanently 在主机端(mac)上,我认为您应该按照这些说明操作:https://support.apple.com/kb/PH18707?locale=en_US

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接