Ubuntu environment uses vagrant to build a virtual development environment

Source: Internet
Author: User

Vagrant is a tool for building a complete virtual development environment, usually abbreviated to VDE (virtual development environment).
Vagrant saves a lot of time in rebuilding the operating system environment, it is also a configuration center that allows you to manage and deploy multiple VDE using a single configuration.
While installing vagrant, you also need to install VirtualBox as it is the core function of vagrant.


1, installation VirtualBox
sudo apt-get install VirtualBox

2. Vagrant is a ruby-developed, All-you-install ruby-related thing
sudo apt-get-y install ruby RubyGems

3. Download the Deb package at Vagrant website
wget Https://releases.hashicorp.com/vagrant/1.9.0/vagrant_1.9.0_x86_64.deb
sudo dpkge-i vagrant_1.9.0_x86_64.deb

or install directly using Apt-get
$ sudo apt-get install vagrant

4, download the official package of the basic image, I download here is Ubuntu64, is a file format box
wget Http://files.vagrantup.com/lucid64.box

5. Name the Lucid64.box
mkdir box_ubuntu16
MV Lucid64.box/home/toby/box_ubuntu16/ubuntu16.box

6. Create a development directory
mkdir Ubuntu16_dev
CD Ubuntu16_dev

7. Add image to Vagrant (name Ubuntu16_dev is box name)
[Email protected]:~/ubuntu16_dev$ vagrant Box Add Ubuntu16_dev/home/toby/box_ubuntu16/ubuntu16.box

8, initialize the development environment (if the previous step to add the box name is not base, then you need to specify the name when initializing, the default is base)
[Email protected]:~/ubuntu16_dev$ vagrant Init Ubuntu16_dev
[Email protected]:~/ubuntu16_dev$ ls-l
-rw-rw-r--1 Toby Toby 3016 DiC 2 00:29 vagrantfile #初始化成功后会生成这个配置文件

9. Modify the settings
After the Vagrant initialization succeeds, a vagrantfile configuration file is generated in the initialized directory, which can be customized by modifying the configuration file.
Vagrant By default is to use port mapping method to map the port of the virtual machine locally to achieve similar http://localhost:80 this way of access, this method is more troublesome, new open and modify the port when you have to edit. In comparison, the host-only mode appears to be much more convenient. Open the Vagrantfile and remove the comment from the line below (remove #) and Save:
Config.vm.network:p rivate_network, IP: "192.168.33.10"
Restart the virtual machine so that we can access the machine with 192.168.33.10, you can change the IP to another address as long as there is no conflict on the line.
There are a lot of configuration changes follow up and then continue to explain;

10. Start the virtual machine
Execute the following command under the command-line working directory to start the virtual machine
Vagrant up
You will see that the terminal shows the start-up process, and after the boot is complete, we can login to the virtual machine with SSH, and the rest of the steps are to configure the various environments and parameters you want to run in the virtual machine.

Commands to restart a virtual machine
Vagrant Reload



11, SSH login can also use the Client Connection tool to connect
Vagrant SSH
[Email protected]:~$ #看到这个已经是进来了虚拟机


12. After the connection, switch to the development directory
Cd/vagrant is the/home/toby/ubuntu16_dev on the host.

The/home/toby/ubuntu16_dev directory on the host computer corresponds to the directory in the virtual machine/home/vagran

13. Packing and Distributing
When you've configured your development environment
Exit and shut down the virtual machine. To package the development environment in the terminal:
Vagrant Package

When the package is complete, a Package.box file is generated in the current directory, and the file is passed on to other users, and other users simply add the box and initialize their development directory to get an identical development environment.

14. Common Commands
Vagrant Init # Initialization
Vagrant up # To start a virtual machine
Vagrant Halt # Shut down the virtual machine
Vagrant Reload # Restart virtual machine
Vagrant SSH # SSH to virtual machine
Vagrant Status # View virtual machine health status
Vagrant Destroy # Destroys the current virtual machine

This article is from the "Fa&it-Q Group: 223843163" blog, please be sure to keep this source http://freshair.blog.51cto.com/8272891/1878893

Ubuntu environment uses vagrant to build a virtual development environment

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.