To use Vagrant on windows 7, first download and install the following on your host machine:
Vagrant lets you manage VM lifecycle, provisioning VM, replicate environments, and includes features like synced folders to make development easier. Since Windows does not come with ssh by default we are going to use MinGW which comes installed with Git to ssh into our vagrant box. Alternatively you may use Cygwin or Putty to ssh into your machine. Lastly, VirtualBox will be used as our provider.
After you install Vagrant, you will be prompted to restart your machine. By default Vagrant installs itself in
c:/HashiCorp/Vagrant/bin. It will also take care of adding itself to your windows path. Having vagrant in our path will allow us to execute vagrant.exe globally instead of having to navigating to the install folder every time we want to run vagrant. Type the following:
If it fails then make sure vagrant is added to your path in environmental variables under system variables. Now lets get started by initializing a directory so that we can use Vagrant.
mkdir vagrant_getting_started cd vagrant_getting_started vagrant init
ls and you will see that Vagrant created a Vagrantfile. The Vagrant file is used to describe what you want to configure and provision for.
Now add the base box. This is the box we will use to do our initial clone. It will grab the base box from HashiCorp’s Atlas box catalog.
vagrant box add hashicorp/precise64
Use vi to edit your
Vagrantfile to modify line
config.vm.box="base" to the following below:
config.vm.box = "hashicorp/precise64"
Choose VirtualBox option when prompted. Once it finishes type:
This will spin up a new VM with the precise64 base box which is basically a minimal ubuntu image. To work with your VM ssh into it.
Navigate to your share directory
All files here are shared with your host machine. That means you can use your host machine’s IDE or editor rather than having to do work using VI or nano. Which simplifies your life as a developer. Another advantage is you can share your boxes with teammates and they will have the exact same environment so that whatever works on your machine will also work on any team members machine.