How To Install Vagrant on Ubuntu 22.04 LTS
In this tutorial, we will show you how to install Vagrant on Ubuntu 22.04 LTS. For those of you who didn’t know, Vagrant is a command-line tool for building and managing virtual development environments. It allows developers to easily create and configure lightweight, reproducible, and portable development environments. By default, Vagrant can provision machines on top of VirtualBox, Hyper-V, and Docker too.
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 the step-by-step installation of the Vagrant on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Vagrant on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install python3-dev libffi-dev git python3-pip python3-testresources libssl-dev wkhtmltopdf gcc g++ make python3.10-venv -y
Step 2. Installing VirtualBox.
Vagrant requires a virtualization platform, such as VirtualBox, to create and manage virtual machines. You can install VirtualBox by following the instructions below:
sudo apt install virtualbox
For additional resources on installing VirtualBox, read the post below:
Step 3. Installing Vagrant on Ubuntu 22.04.
By default, the Vagrant is not available on Ubuntu 22.04 base repository. Now run the following command below to add the Vagrant repository and GPG keys to your Ubuntu system:
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
After the repository was added, now update apt packages and install the latest version of Vagrant using the following command below:
sudo apt update sudo apt install vagrant
We will run the check version command to ascertain whether or not we successfully installed Vagrant on our Ubuntu system:
vagrant --version
Step 4. Creating a Vagrant Environment.
Once Vagrant is installed, you can use it to create and manage virtual development environments. Here is a simple example of how to create a Vagrant environment:
mkdir my_env cd my_env
Next, initialize the Vagrant environment by running the following command:
vagrant init
Finally, start the Vagrant environment by running the following command below:
vagrant up
After the environment is up and running, you can use the following command to log in to the virtual machine:
vagrant ssh
Congratulations! You have successfully installed Vagrant. Thanks for using this tutorial for installing Vagrant on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official Vagrant website.