In this tutorial, we will show you how to install Vagrant on Ubuntu 20.04 LTS. For those of you who didn’t know, a Vagrant is a command-line tool for building and managing virtual machines. By default, Vagrant can provision machines on top of VirtualBox, Hyper-V, and Docker. Other providers such as Libvirt (KVM), VMware, and AWS can be installed via the Vagrant plugin system. Vagrant is typically used by developers to set up a development environment that works across multiple operating systems.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of a Vagrant virtual development environment on an Ubuntu 20.04 Focal Fossa server.
Install Vagrant on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt-get commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Installing VirtualBox.
Install Virtualbox using the following command:
sudo apt install virtualbox
Step 3. Installing Vagrant on Ubuntu 20.04.
First, download the latest stable version of Vagrant. Visit the Vagrant downloads page to see if there is a new version of Vagrant available:
curl -O https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb
Once the file is downloaded, install using the following command:
sudo apt install ./vagrant_2.2.9_x86_64.deb
To verify that the installation was successful run the following command which will print the Vagrant version:
Step 4. Deploy your development environment.
Creating a Vagrant project is as simple as setting up the project root directory and defining a Vagrantfile. Run the following commands to create the directory:
mkdir ~/my-project cd ~/my-project
Next, initialize a new Vagrantfile using the vagrant init command, followed by the box you want to use. In this example, we will use the centos/8 box:
vagrant init centos/8
vagrant up the command to create and configure the virtual machine as specified in the Vagrantfile:
To ssh into the virtual machine, run:
You can stop the virtual machine with the following command:
To destroy all resources created during the creation of the machine, enter:
Congratulations! You have successfully installed Vagrant. Thanks for using this tutorial for installing the Vagrant virtual development environment on your Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you to check the official Vagrant website.