解决 Vagrant 运行本地项目响应缓慢问题

在公司 PHP 开发环境下,有时候本地运行有些缓慢的情况,所以使用 NFS 插件解决一下

参考文献

解决 Windows 系统使用 Homestead 运行 Laravel 本地项目响应缓慢问题)

VAGRANT NFS

安装

首先,命令行进入 Vagrant 启动目录,然后运行安装命令:

1
vagrant plugin install vagrant-winnfsd

安装成功后修改目录下的 Vagrantfile 配置文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "centos7-lnmp"

config.ssh.insert_key = false
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"

config.vm.network "private_network", ip: "192.168.56.10"

#config.vm.network "public_network"

config.vm.synced_folder "D:/website", "/data/wwwroot", type: "nfs"

config.vm.synced_folder 最后加上 type: 'nfs'

然后重启虚拟机:

1
vagrant reload

实测安装后速度有部分提升!