运行命令vagrant up并获取默认值:warning:connection timeout。重试

时间:2015-12-17 16:20:31

标签: php laravel cmd vagrant homestead

我已经查看了其他一些关于此事的帖子,他们说的一半内容因此对我来说或他们说在终端中运行的命令回来时找不到命令。我有一个Windows操作系统,这可能是问题。如果你遇到windows的这个问题,请帮忙!

我已禁用防火墙,但没有做任何事情。

Vagrantfile:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

1 个答案:

答案 0 :(得分:0)

好的,因为问题与 VT-x / AMD-V硬件加速有关,你应该有两个选择:

  1. 如果您的硬件支持BIOS,则可以从您的BIOS启用虚拟化(可能会在您的设置中关闭)

  2. 如果你的硬件/ CPU不支持它,请告诉vagrant通过在你的Vagrantfile中添加它来关闭hw虚拟化

    config.vm.provider :virtualbox do |vb| 
      vb.customize ["modifyvm", :id, "--hwvirtex", "off"]
    end
    
  3. 类似

    require 'json'
    require 'yaml'
    
    VAGRANTFILE_API_VERSION = "2"
    confDir = $confDir ||= File.expand_path("~/.homestead")
    
    homesteadYamlPath = confDir + "/Homestead.yaml"
    homesteadJsonPath = confDir + "/Homestead.json"
    afterScriptPath = confDir + "/after.sh"
    aliasesPath = confDir + "/aliases"
    
    require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
    
    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
        if File.exists? aliasesPath then
            config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
        end
    
        if File.exists? homesteadYamlPath then
            Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
        elsif File.exists? homesteadJsonPath then
            Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
        end
    
        if File.exists? afterScriptPath then
            config.vm.provision "shell", path: afterScriptPath
        end
    
        config.vm.provider :virtualbox do |vb| 
          vb.customize ["modifyvm", :id, "--hwvirtex", "off"]
        end
    end