安装

  • 虚拟化平台

    在安装 vagrant 之前需要先安装虚拟化平台,vmware(收费) 或者 virtualBox(免费)。

    • 安装 vmware 官网 下载 .exe 安装包安装vmware。

    • 安装 virtualBox 官网 下载 .exe 安装包安装virtualBox。

      vmware 与 virtualBox 可以任意选择一个

  • Vagrant

    下载vagrant 下载 下载对应的系统及系统位数。

    安装完成后添加box注意选择对应的虚拟化平台

vagrant 常用命令

使用 vagrant --help 查看命令格式及常用命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

λ vagrant --help
Usage: vagrant [options] <command> [<args>]

-h, --help Print this help.

Common commands:
box manages boxes: installation, removal, etc.
cloud manages everything related to Vagrant Cloud
destroy stops and deletes all traces of the vagrant machine
global-status outputs status Vagrant environments for this user
halt stops the vagrant machine
help shows the help for a subcommand
init initializes a new Vagrant environment by creating a Vagrantfile
login
package packages a running vagrant environment into a box
plugin manages plugins: install, uninstall, update, etc.
port displays information about guest port mappings
powershell connects to machine via powershell remoting
provision provisions the vagrant machine
push deploys code in this environment to a configured destination
rdp connects to machine via RDP
reload restarts vagrant machine, loads new Vagrantfile configuration
resume resume a suspended vagrant machine
snapshot manages snapshots: saving, restoring, etc.
ssh connects to machine via SSH
ssh-config outputs OpenSSH valid configuration to connect to the machine
status outputs status of the vagrant machine
suspend suspends the machine
up starts and provisions the vagrant environment
upload upload to machine via communicator
validate validates the Vagrantfile
version prints current and latest Vagrant version
winrm executes commands on a machine via WinRM
winrm-config outputs WinRM configuration to connect to the machine

For help on any individual command run `vagrant COMMAND -h`

Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.
--[no-]color Enable or disable color output
--machine-readable Enable machine readable output
-v, --version Display Vagrant version
--debug Enable debug output
--timestamp Enable timestamps on log output
--debug-timestamp Enable debug output with timestamps
--no-tty Enable non-interactive output
管理box

首先可以执行 vagrant box --help 命令查看如何管理box

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

λ vagrant box --help
Usage: vagrant box <subcommand> [<args>]

Available subcommands:
add
list
outdated
prune
remove
repackage
update

For help on any individual subcommand run `vagrant box <subcommand> -h`
--[no-]color Enable or disable color output
--machine-readable Enable machine readable output
-v, --version Display Vagrant version
--debug Enable debug output
--timestamp Enable timestamps on log output
--debug-timestamp Enable debug output with timestamps
--no-tty Enable non-interactive output
  • 添加 box
1
2

λ vagrant box add laravel/homestead
box下载地址
box下载地址

如果 box下载缓慢,可以用其他方式下载box,然后从本地安装box