简体   繁体   中英

Vagrant Homestead slow

I have a vagrant server based off Laravel Homestead for testing my Laravel sites locally for the most part it runs great. However, recently, I have been having problems where it will just halt for anything from a few minutes (typical) to hours (rare). This happens every 15 minutes or so. To the point where if I'm typing in the ssh connection it will just stop. Then when I check back a few minutes later, what I had been typing is now there. This isn't just SSH and pages stop loading, and vagrant commands including rsync and even halt fail.

This is vanilla Homestead, except for I changed the mapping to be via rsync (manual, I run the rsync command whenever I want to update the server). The reason for this was because I was getting 30second or so load times for webpages and after research and trying rsync this helped massively for this. Also, I have (since the problem) tried giving it access to all 4 cpus. I am running this on a macbook air 2013 if this is important. It has been running fine for the past 2 months. The vagrant server is running with 2048MB of memory and I have 15GB of disk space free.

This is a very frustrating problem as it slows down development massively.

edit : This seems to happen most frequently (but not exclusively) when using the mysql command line over ssh

I had the same issue on windows and this fixed it:

install this vagrant plugin: vagrant plugin install vagrant-winnfsd

then add this to your homestead.yaml : type: nfs

yaml file should look like this:

folders:
    - map: C:\my-www
      to: /home/vagrant/my-www
      type: nfs

when all is done destroy your vagrant and do vagrant up .

I had this problem. Laravel with Vagrant box was extremely slow. I tried different available settings of the VM, increased VM resources, changed PHP-fpm settings, checked database performance and so on with no result.

What actually helped:

  1. Update vagrant to latest version - go to vagrant website download and install. onto the old version
  2. Install NFS plugin vagrant plugin install vagrant-winnfsd

    vagrant plugin install vagrant-winnfsd

  3. Install Virtual Box guest plugin

    vagrant plugin install vagrant-vbguest

  4. Edit vendor\\laravel\\homestead\\scripts\\homestead.rb as follows:

4.1 Remove or comment line:

mount_opts = folder['mount_options'] ? folder['mount_options'] : ['actimeo=1', 'nolock']

4.1 Change line:

config.vm.synced_folder folder['map'], folder['to'], type: folder['type'] ||= nil, **options

to

config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, :nfs => true
  1. Add the following line in Homestead.yaml under folders:/to

    type: nfs

  2. Restart vagrant

    vagrant reload

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM