正文
在win10上装了virtualBox和vagrant配置的linux环境,但是随着时间的推移,vagrant访问速度越来越慢,怎么解决呢?下面说一下。
在win10的cmd命令行中,cd到vagrant目录下:
vagrant global-status
可以看到下面近似的提示:
D:\vagrant>vagrant global-status
id name provider state directory
-------------------------------------------------------------------------
3989dad default virtualbox poweroff D:/vagrant
The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"
接着destroy:
vagrant --force destroy 3989dad
例:
D:\vagrant>vagrant --force destroy 3989dad
default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...
然后再up:
vagrant up
发现速度又恢复变快了。原因未找到,可能是虚拟机运行时间长了,里面垃圾太多导致的,不过解决办法是有了,以后变慢了就如上操作吧。
vagrant destroy 会清理nginx配置,结果造成js乱码或者页面缓存,需要修改nginx配置:
cd /etc/nginx
sudo vi nginx.conf
把sendfile on改为sendfile off:
sendfile off