Configure the Vagrant environment in Windows

Source: Internet
Author: User
Tags putty ssh client

Configure the Vagrant environment in Windows

Vagrant is a Ruby-based tool used to create and deploy a virtualized development environment. It uses the open-source VirtualBox virtualization System of Oracle.

Vagrant is very good at setting up a development environment quickly. Imagine that everyone in a team is developing the same thing. In the past, everyone had to build a development environment by themselves. With Vagrant, you only need to build one copy and distribute it to all the team members so that everyone has the same development environment immediately, even if some members are in Windows, you can also conveniently use the Linux environment for development. If a new employee is in the team, you don't need to teach him how to build a development environment. Just drop him a Box, as long as he has mastered the Vagrant usage method, it can be integrated into development immediately without the need to install complex environments.

The cross-platform features of Vagrant are amazing, and they all benefit from VirtualBox's outstanding software and talented engineers such as Vagrant.

Vagrant also supports the use of Chef and Puppet to maintain your virtual development environment. However, I am not familiar with these two tools and will not introduce them in this article, this section describes how to configure a Vagrant environment in Windows.

Install Vagrant

Download the latest Vagrant and the corresponding VirtualBox installation from the official Vagrant website, and create a folder to configure Vagrant.

Because vagrant init precise32 http://files.vagrantup.com/precise32.boxcommand downloading box is slow, it is best to use thunder and other tools in advance to download box in a file, and then use the local path during initialization, it will be much quicker.

vagrant init precise32 ..\boxes\precise32.box

Note that when using a local path, you need to use a Windows path, that is, use \ as the path separator.

PS: available Vagrant Boxes see here: http://www.vagrantbox.es/

Port forwarding

It is very convenient to configure port forwarding in Vagrant.

Vagrant.configure("2") do |config|  # other config here  config.vm.network :forwarded_port, guest: 80, host: 8080end

The above configuration will establish a forwarding relationship between port 80 in Vagrant and port 8080 on your local machine, so that you access http: // localhost: 8080 on your local machine is equivalent to accessing http in Vagrant: // localhost: 80.

Multiple groups can be configured for port forwarding.

Shared Folder

One important step to use Vagrant is to share folders (thanks to the powerful VirtualBox)

Set in Vagrantfile

config.vm.synced_folder "E:/Blog", "/home/vagrant/Blog"

Here, the first parameter E:/Blog is the folder path to be shared on this machine, and the second parameter is the ing path in the Vagrant Virtual Machine. Note that the second parameter must use the absolute path, for example,/home/vagrant/Blog

Connect to Vagrant

After configuration, you can start the Virtual Machine and connect to Vagrant.

First, run vagrant up. Wait for a moment and the vagrant will be started. ::

e:\Vagrant\precise32>vagrant reload[default] Attempting graceful shutdown of VM...[default] Setting the name of the VM...[default] Clearing any previously set forwarded ports...[default] Creating shared folders metadata...[default] Clearing any previously set network interfaces...[default] Preparing network interfaces based on configuration...[default] Forwarding ports...[default] -- 22 => 2222 (adapter 1)[default] -- 5000 => 5000 (adapter 1)[default] -- 3000 => 3000 (adapter 1)[default] Booting VM...[default] Waiting for VM to boot. This can take a few minutes.[default] VM booted and ready for use![default] Configuring and enabling network interfaces...[default] Mounting shared folders...[default] -- /vagrant[default] -- /home/vagrant/Blog[default] -- /home/vagrant/Notes[default] -- /home/vagrant/Projects

If you modify Vagrantfile after vagrant up, you need to execute vagrant reload

In Windows, you cannot use vagrant ssh to directly access vagrnat. However, this command will show you how to connect to vagrant through ssh ::

e:\Vagrant\precise32>vagrant ssh`ssh` executable not found in any directories in the %PATH% variable. Is anSSH client installed? Try installing Cygwin, MinGW or Git, all of whichcontain an SSH client. Or use the PuTTY SSH client with the followingauthentication information shown below:Host: 127.0.0.1Port: 2222Username: vagrantPrivate key: C:/Documents and Settings/greatghoul/.vagrant.d/insecure_private_key

In this way, you can use an ssh client similar to putty to access vagrant for development. Chrome extension Secure Shell is strongly recommended here.

For details about Vagrant, click here
Vagrant: click here

How to Use vagrant to install a Hadoop cluster on a virtual machine

Efficient Puppet module Management in Vagrant

Use Vagrant and Fabric for Integration Testing

Build a development environment using Vagrant

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.