In this tutorial we will show you how to install Vagrant on Ubuntu 20.04 LTS. For those of you who didn’t know, 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 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 these following apt-get commands in the terminal.
Install Virtualbox using following command:
First, download the latest stable version of Vagrant. Visit the Vagrant downloads page to see if there is a new version of Vagrant available:
Once the file is downloaded, install using following command:
To verify that the installation was successful run the following command which will print the Vagrant version:
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:
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 up 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:
Congratulation’s! You have successfully installed Vagrant. Thanks for using this tutorial for installing 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.