注意: 此方法可能帶來未知反作用,請操做以前務必備份原配置文件!!laravel
使用 win7 電腦學習第二本教程,發現項目運行起來切換頁面每次都要 7-10 s,很不正常啊,部署到服務器發現加載僅須要 200 ms 左右。
web
嘗試過增長虛擬機配置, 可是沒有任何效果, 通過驗證也不是數據庫的緣由,經過網上查詢瞭解到, 是由於 VirtualBox 的 IO 引發的。shell
解決方案是安裝NFS Plugin
,參考文章(英文)數據庫
英文很差的小夥伴接着看 ~windows
首先,命令行進入 Homestead 啓動 vagrantbash
> cd ~/Homestead && vagrant up複製代碼
而後運行安裝命令服務器
$ vagrant plugin install vagrant-winnfsd複製代碼
如上圖,安裝成功後修改配置文件學習
修改配置文件前建議先備份,以避免修改後出現問題!ui
文件1:homestead/scripts/homestead.rb
spa
# Register All Of The Configured Shared Folders
if settings.include? 'folders'
settings["folders"].each do |folder|
if File.exists? File.expand_path(folder["map"])
mount_opts = []
if (folder["type"] == "nfs")
mount_opts = folder["mount_options"] ? folder["mount_options"] : ['actimeo=1', 'nolock']
elsif (folder["type"] == "smb")
mount_opts = folder["mount_options"] ? folder["mount_options"] : ['vers=3.02', 'mfsymlinks']
end
# For b/w compatibility keep separate 'mount_opts', but merge with options
options = (folder["options"] || {}).merge({ mount_options: mount_opts })
# Double-splat (**) operator only works with symbol keys, so convert
options.keys.each{|k| options[k.to_sym] = options.delete(k) }
config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, **options
# Bindfs support to fix shared folder (NFS) permission issue on Mac
if Vagrant.has_plugin?("vagrant-bindfs")
config.bindfs.bind_folder folder["to"], folder["to"]
end
else
config.vm.provision "shell" do |s|
s.inline = ">&2 echo \"Unable to mount one of your folders. Please check your folders in Homestead.yaml\""
end
end
end
end複製代碼
查找此段代碼(可能略有不一樣),替換爲如下內容
if settings.include? 'folders'
settings["folders"].sort! { |a,b| a["map"].length <=> b["map"].length }
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複製代碼
文件2:Homestead.yaml
folders:
- map: ~/Code
to: /home/vagrant/Code
type: nfs複製代碼
重啓 Homestead 使配置文件生效,大功告成。再次運行項目響應時間已經正常了,但願幫助有相同狀況的小夥伴!