laravel 如何为 Vagrant 安装手动下载的 .box

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26655516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:20:58  来源:igfitidea点击:

How to Install Manually Downloaded .box for Vagrant

laravelvagrantubuntu-14.04

提问by Port 8080

I manage to install Vagrant on my Ubuntu 14.04 LTS pc. How can I install vagrant box which I downloaded manually from a URL? I want to install Laravel Homestead but it will always fail because of my network connection. I want to download it from this link https://vagrantcloud.com/laravel/boxes/homestead/versions/11/providers/virtualbox.boxbut I don't know what to do after I downloaded the box.

我设法在我的 Ubuntu 14.04 LTS 电脑上安装了 Vagrant。如何安装从 URL 手动下载的 vagrant box?我想安装 Laravel Homestead 但它总是会因为我的网络连接而失败。我想从这个链接下载它,https://vagrantcloud.com/laravel/boxes/homestead/versions/11/providers/virtualbox.box但我不知道下载盒子后该怎么做。

回答by

You can install downloaded box using this command

您可以使用此命令安装下载的框

vagrant box add laravel/homestead path/to/your/box/file.box

vagrant box add laravel/homestead path/to/your/box/file.box

Source: https://laracasts.com/forum/?p=1615-laravel-vagrant-homestead/0

来源:https: //laracasts.com/forum/?p=1615-laravel-vagrant-homestead/0

回答by sawran

I am able to run this command on win7:

我可以在 win7 上运行这个命令:

box add homestead file:///c:/homestead.box

Also this one is working:

这也是一个工作:

box add homestead file:///c:\homestead.box

回答by Jakhongir

Boxes also can be added using metadata json file, in which some additional configs can be provided, along with box name and its local path.

还可以使用元数据 json 文件添加框,其中可以提供一些额外的配置,以及框名称及其本地路径。

For example create metadata.json file and provide version (7.0.0) of importing box in it:

例如创建 metadata.json 文件并在其中提供导入框的版本 (7.0.0):

{
  "name": "laravel/homestead",
  "versions": [
    {
      "version": "7.0.0",
      "providers": [
        {
          "name": "virtualbox",
          "url": "file:///Users/path/to/box/virtualbox.box"
        }
      ]
    }
  ]
}

Then add box running vagrant box addcommand with metadata.json file path parameter:

然后vagrant box add使用 metadata.json 文件路径参数添加框运行命令:

vagrant box add laravel/homestead /path/to/metadata.json



Additional info:When version is not provided, imported box will have version 0 by default. And if there is check for minimum box version, when running vagrant upit will start to download box from internet instead of using already imported one.



附加信息:当未提供版本时,默认情况下导入的框将具有版本 0。如果有检查最低盒子版本,运行时vagrant up它会开始从互联网下载盒子,而不是使用已经导入的盒子。