How to install Vagrant on Ubuntu 20.04

Article Directory

This article was first published in: https://www.itcoder.tech/posts/how-to-install-vagrant-on-ubuntu-20-04/

Vagrant is a command line tool for building and managing virtual development environments.

By default, Vagrant prepares the environment on VirtualBox, Hyper-V, and Docker. Support other providers, for example, Libvirt (KVM), VMware and AWS can be enabled through the Vagrant plug-in system.

Vagrant is usually used by developers to build a development environment that matches the production environment.

This article describes how to install Vagrant on an Ubuntu 20.04 machine. We will use VirtualBox, the default provider of Vagrant.

1. Install Vagrant on Ubuntu

We will provide virtual machines based on VirtualBox.

If VirtualBox is not installed on your system, you can install it by running the following command:

sudo apt update
sudo apt install virtualbox

The Vagrant package is provided in the Ubuntu source repository and is not frequently updated. We will download and install the latest version of Vagrant from the official Vagrant website.

At the time of writing this article, the latest version of Vagrant is 2.2.9. Browse Vagrant download page to see if the latest version of Vagrant is available.

Use wget to download the Vagrant package:

curl -O https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb

Once the download is complete, enter the following command to install it:

sudo apt install ./vagrant_2.2.9_x86_64.deb

To verify that the installation was successful, run the following command to print the Vagrant version:

vagrant --version

The output is similar to the following:

Vagrant 2.2.9

2. Getting Started with Vagrant##

Creating a Vagrant project is very simple, define a Vagrantfile in the project root directory.

Run the following command to create a folder, and cd to switch to this directory:

mkdir ~/my-vagrant-project
cd ~/my-vagrant-project

Next, use vagrant init plus the box you want to use to initialize a new Vagrantfile.

The box is the package format of the Vagrant environment. You can find the box list in Vagrant box page.

In this example, we use the centos/8 box:

vagrant init centos/8

Output:

A `Vagrantfile` has been placed inthis 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.

Vagrantfile is a Ruby file that describes how to configure and provide virtual machines. You can open Vagrantfile, read the notes, and make adjustments according to your own needs.

Run the vagrant up command to create and configure the virtual machine according to the content specified in the Vagrantfile.

vagrant up
==> default: Configuring and enabling network interfaces...default: SSH address:192.168.121.74:22default: SSH username: vagrant
 default: SSH auth method:private key
==> default: Rsyncing folder:/home/linuxize/Vagrant/my-vagrant-project/=>/vagrant

Vagrant mounts the project directory to the /vagrant directory of the virtual machine. This allows you to manipulate your project files on your host.

To access your virtual machine using SSH, run:

vagrant ssh

You can stop the virtual machine with the following command:

vagrant halt

To release all resources in the process of creating a virtual machine, enter:

vagrant destroy

Three, summary##

We showed you how to install Vagrant on Ubuntu 20.04 and create a basic Vagrant project.

To find more information about Vagrant, visit Vagrant official documentation page.

If you have any questions, please contact us in the following ways:

WeChat:

WeChat group: add the above WeChat, remark the WeChat group

QQ: 3217680847

QQ Group: 82695646

Recommended Posts

How to install Vagrant on Ubuntu 20.04
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Vagrant on CentOS 8
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 20.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install Bacula Server on Ubuntu 14.04
How to install MySQL on Ubuntu 18.04 (linux)
How to install Ubuntu 19.10 on Raspberry Pi 4
How to install Apache Kafka on Ubuntu 18.04
How to install Apache Maven on Ubuntu 20.04
How to install Apache Tomcat 8 on Ubuntu 16.04
How to install Python2 on Ubuntu20.04 ubuntu/focal64
How to install GCC compiler on Ubuntu 18.04
How to install Graylog 1.x on Ubuntu 14.04.