Laravel Homestead/Vagrant/Virtualbox 在 Windows 上运行缓慢
Laravel Homestead/Vagrant/Virtualbox is slow on Windows
我已经在 Windows
上安装了 Laravel Homestead/Vagrant/Virtualbox
,正如在 official site
上所说的那样
但是真的很慢。页面更新大约需要5秒。
这不仅仅是我的观察。 Laracast 对此进行了讨论。
laracast 论坛有一些有趣的想法,但那里很乱(对不起 Jeffery),很难理解哪些想法被接受,哪些被拒绝。
在 Whosebug 上,我们有一个很好的投票系统来投票选出可行的解决方案,并要求作者分别为每个解决方案提供更多详细信息。请post您的解决方案和经验。
根据我的经验 - 有一次 windows 运行 更新并强行关闭我的系统,当它启动时它非常快(至少快 10 倍)但是之后下次重新启动它又变慢了。现在我知道可以做一些事情来加快它的速度,它不是“slow hardware case
”,它是一个软件配置案例!
我在 Intel-Core-i7 上使用 Windows-10,使用 Oracle Virtualbox-5.2.12...(一切都是最新的,没有什么要更新的)
在 laracasts 论坛上,名为 @phazei
的作者已在 3 年前回答过
他说的是:
1) 在您的 Windows 主机上安装插件,为 Windows 中的 vagrant 添加 NFS 支持。
$ vagrant plugin install vagrant-winnfsd
2) 找到你的 homestead.rb
我在
中找到了它
C:\Users\username\Homestead\scripts
尽管他建议看
C:\Users\username\AppData\Roaming\Composer\vendor\laravel\homestead\scripts
3)
Find the section where it's already looping through the settings["folders"] and replace it with the nfs code.
对我来说是第 140 行左右。
所以,我注释掉了所有语句if settings.include? 'folders' ... end
并添加了这个:
# EDIT:
# Reorder folders for winnfsd plugin compatilibty
# see https://github.com/GM-Alex/vagrant-winnfsd/issues/12#issuecomment-78195957
settings["folders"].sort! { |a,b| a["map"].length <=> b["map"].length }
# Register All Of The Configured Shared Folders
if settings.include? 'folders'
settings["folders"].each do |folder|
config.vm.synced_folder folder["map"], folder["to"],
id: folder["map"],
:nfs => true,
:mount_options => ['nolock,vers=3,udp,noatime']
end
end
4) 然后用 halt/up 重新启动 vagrant,我的页面加载速度从 8 秒增加到 2 秒。
谢谢@phazei
。 3 年后,您的答案仍然有效。
PS
我在 windows 10 上用 Oracle Virtualbox-5.2.12,vagrant version-2.1.1 测试了它。
PPS
您可以运行vagrant up --provision
,不会影响您在homestead.rb
中所做的更改
NFS 代表 Network File System
,您需要它来提高速度。
Laravel homestead tutorial
没有说明 NFS
是什么以及为什么需要它,这就是我在初始安装时忽略它的原因。
1) 在你的 Windows 主机上,在 Windows.
中安装为 vagrant 添加 NFS 支持的插件
$ vagrant plugin install vagrant-winnfsd
2) 转到Homestead.yaml
,它通常位于C:\Users\username\Homestead\Homestead.yaml
3) 在文件夹部分添加 type: "nfs"
,如下所示:
folders:
- map: ~/code
to: /home/vagrant/code
type: "nfs"
4) 运行 vagrant up --provision
结果:
速度增加,如 @phazei's
回答,每个请求从 8 秒增加到 2 秒,但工作量要少得多。 @phazei's
回答澄清了一些后台进程。
我在 windows 10 上用 Oracle Virtualbox-5.2.12,vagrant version-2.1.1 测试了它。
请注意:
Vagrant NFS page 说
Windows users: NFS folders do not work on Windows hosts. Vagrant will ignore your request for NFS synced folders on Windows.
不过如果你有插件的话,可以忽略。
我已经在 Windows
上安装了 Laravel Homestead/Vagrant/Virtualbox
,正如在 official site
但是真的很慢。页面更新大约需要5秒。
这不仅仅是我的观察。 Laracast 对此进行了讨论。
laracast 论坛有一些有趣的想法,但那里很乱(对不起 Jeffery),很难理解哪些想法被接受,哪些被拒绝。
在 Whosebug 上,我们有一个很好的投票系统来投票选出可行的解决方案,并要求作者分别为每个解决方案提供更多详细信息。请post您的解决方案和经验。
根据我的经验 - 有一次 windows 运行 更新并强行关闭我的系统,当它启动时它非常快(至少快 10 倍)但是之后下次重新启动它又变慢了。现在我知道可以做一些事情来加快它的速度,它不是“slow hardware case
”,它是一个软件配置案例!
我在 Intel-Core-i7 上使用 Windows-10,使用 Oracle Virtualbox-5.2.12...(一切都是最新的,没有什么要更新的)
在 laracasts 论坛上,名为 @phazei
的作者已在 3 年前回答过
他说的是:
1) 在您的 Windows 主机上安装插件,为 Windows 中的 vagrant 添加 NFS 支持。
$ vagrant plugin install vagrant-winnfsd
2) 找到你的 homestead.rb
我在
中找到了它C:\Users\username\Homestead\scripts
尽管他建议看
C:\Users\username\AppData\Roaming\Composer\vendor\laravel\homestead\scripts
3)
Find the section where it's already looping through the settings["folders"] and replace it with the nfs code.
对我来说是第 140 行左右。
所以,我注释掉了所有语句if settings.include? 'folders' ... end
并添加了这个:
# EDIT:
# Reorder folders for winnfsd plugin compatilibty
# see https://github.com/GM-Alex/vagrant-winnfsd/issues/12#issuecomment-78195957
settings["folders"].sort! { |a,b| a["map"].length <=> b["map"].length }
# Register All Of The Configured Shared Folders
if settings.include? 'folders'
settings["folders"].each do |folder|
config.vm.synced_folder folder["map"], folder["to"],
id: folder["map"],
:nfs => true,
:mount_options => ['nolock,vers=3,udp,noatime']
end
end
4) 然后用 halt/up 重新启动 vagrant,我的页面加载速度从 8 秒增加到 2 秒。
谢谢@phazei
。 3 年后,您的答案仍然有效。
PS
我在 windows 10 上用 Oracle Virtualbox-5.2.12,vagrant version-2.1.1 测试了它。
PPS
您可以运行vagrant up --provision
,不会影响您在homestead.rb
NFS 代表 Network File System
,您需要它来提高速度。
Laravel homestead tutorial
没有说明 NFS
是什么以及为什么需要它,这就是我在初始安装时忽略它的原因。
1) 在你的 Windows 主机上,在 Windows.
中安装为 vagrant 添加 NFS 支持的插件$ vagrant plugin install vagrant-winnfsd
2) 转到Homestead.yaml
,它通常位于C:\Users\username\Homestead\Homestead.yaml
3) 在文件夹部分添加 type: "nfs"
,如下所示:
folders:
- map: ~/code
to: /home/vagrant/code
type: "nfs"
4) 运行 vagrant up --provision
结果:
速度增加,如 @phazei's
回答,每个请求从 8 秒增加到 2 秒,但工作量要少得多。 @phazei's
回答澄清了一些后台进程。
我在 windows 10 上用 Oracle Virtualbox-5.2.12,vagrant version-2.1.1 测试了它。
请注意: Vagrant NFS page 说
Windows users: NFS folders do not work on Windows hosts. Vagrant will ignore your request for NFS synced folders on Windows.
不过如果你有插件的话,可以忽略。