您的位置:首页 > 其它

辛星浅析vagrant的使用

2015-09-21 18:25 162 查看
可能每一个项目都会随着项目参与人数的增加而变得管理困难,没错,不论是在进度管理、任务划分,甚至是连简单的环境搭建,都有可能会出问题。可能一个问题在某个环境下跑的好好地,但是在另一个环境下却问题百出,踩了很多的坑,也因此付出了相当惨痛的代价。

为了方便环境的统一管理,因此两个优秀的产品就出现了,它们分别是vagrant和docker,对于docker我们以后再介绍,这里首先说一下vagrant。

准备工作:

(1)virtualbox 的下载

地址:https://www.virtualbox.org/

(2)vagrant的下载

地址:http://www.vagrantup.com/

(3)然后我们需要统一分配的环境就是若干以.box为后缀的文件啦,这里我们使用的是vanthink_dev.box



开始安装:

(1)首先我们在对应目录下使用vagrant init来初始化一下,如果不是base的话,我们需要指定名称,我们这里不妨设置为van,我们安装过程如下:

C:\wamp\www\xinguimeng>vagrant init van
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.


(2)然后我们使用vagrant box add box目录 来把对应的box添加到这个虚拟机中,过程如下:

C:\wamp\www\xinguimeng>vagrant box add van vanthink_dev.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'van' (v0) for provider:
    box: Unpacking necessary files from: file://C:/wamp/www/xinguimeng/vanthink_dev.box
    box: Progress: 100% (Rate: 19.5M/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'van' (v0) for 'virtualbox'!
(3)然后我们使用vagrant up来启动此虚拟机,过程如下:

C:\wamp\www\xinguimeng>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'van'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: xinguimeng_default_1442824653365_7382
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.1.22
    default: VirtualBox Version: 5.0
==> default: Mounting shared folders...
    default: /vagrant => C:/wamp/www/xinguimeng


至此,我们的vagrant就安装完毕啦。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: