【问题标题】:Homestead 2.0, Vagrant and VirtualBox running a lot slower than MAMPHomestead 2.0、Vagrant 和 VirtualBox 运行速度比 MAMP 慢很多
【发布时间】:2015-02-14 12:52:49
【问题描述】:

我刚刚为在 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!

【问题讨论】:

标签: vagrant virtualbox mamp laravel-5 homestead


【解决方案1】:

我在 reddit/r/laravel 上问过同样的问题,得到了答案:

  1. 在以下位置找到 homestead.rb 文件:/Users/username/.composer/vendor/laravel/homestead/scripts

  2. 关闭虚拟机(宅基地停止)

  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

到:

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" 
  1. 加电(宅基地),这应该会加快速度

来源:http://www.reddit.com/r/laravel/comments/2vvama/homestead_20_vagrant_and_virtualbox_running_a_lot

【讨论】:

  • 或者,根据同一 reddit 帖子,您可以将 type: nfs 添加到每个 folders 映射。
【解决方案2】:

在我的情况下使用Windows作为HOST也是一样的,这是因为VirtualBox使用vboxsf作为文件系统将文件从主机挂载到客户机,我不知道为什么但它太慢了。

在 GUEST (Ubuntu 16.04) 上,我使用 CIFS 将工作文件夹安装为网络文件夹,运行速度更快。

在客人端我使用这个:https://wiki.ubuntu.com/MountWindowsSharesPermanently

在主机端 (mac) 我认为您应该遵循以下说明:https://support.apple.com/kb/PH18707?locale=en_US

【讨论】:

    猜你喜欢
    • 2018-11-09
    • 2021-07-11
    • 2015-05-14
    • 1970-01-01
    • 1970-01-01
    • 2018-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多