Vagrant + Drupal跑得非常慢

时间:2017-01-17 13:59:39

标签: drupal vagrant virtual-machine virtualbox

我使用vagrant来托管多个环境。几个星期前,电力浪涌摧毁了我的VM,这工作得非常好。后端开发人员为我构建了一个新的Vagrant文​​件,但它一直非常慢。在我支持的最大网站上运行drush cc all最多可能需要10分钟。我尝试了很多解决方案,但没有一个能够提供帮助。值得注意的是,加载前向页面比加载管理页面要快得多。使用drush和git也非常慢。

这是我的Vagrantfile:

Vagrant.configure(2) do |config|

    config.vm.provider "virtualbox" do |vb|
          vb.memory = "4096"
    end

  # config.vm.box = "ubuntu/xenial64"
  config.vm.box = "ubuntu/trusty64"

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

  config.vm.synced_folder "www", "/var/www",

    # config.vm.synced_folder "./", "/var/sites/dev.query-auth", id: "vagrant-root"
    owner: "vagrant",
    group: "www-data",
    mount_options: ["dmode=775,fmode=664"]


  config.vm.provision "fix-no-tty", type: "shell" do |s|
    s.privileged = false
    s.inline = "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile"
  end

    config.vm.provision :shell, path: "provision.sh"

end

我见过的常见修复方法是将NFS设置为true,但它对性能没有影响。任何有关如何提高我的表现的提示都会非常有用。

1 个答案:

答案 0 :(得分:0)

这是我的,工作得很好。尝试使用它,或者将它们结合起来。

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "ubuntu/trusty64"

  # Create a private network, which allows host-only access to the machine using a specific IP.
  config.vm.network "private_network", ip: "192.168.33.22"

  # Share an additional folder to the guest VM. The first argument is the path on the host to the actual folder.
  # The second argument is the path on the guest to mount the folder.
  config.vm.synced_folder "./", "/var/www/html", nfs: true

  # Define the bootstrap file: A (shell) script that runs after first setup of your box (= provisioning)
  config.vm.provision :shell, path: "bootstrap.sh"

config.vm.boot_timeout = 3000

 config.vm.provider "virtualbox" do |v|
  # v.gui = true
  v.memory = 3072
  v.cpus = 2
 end


end