Share your love
Install and Use Vagrant on Debian 11
In this article, we want to teach you How To Install and Use Vagrant on Debian 11.
Vagrant is an open-source tool that helps us to automate the creation and management of Virtual Machines. In a nutshell, we can specify the configuration of a virtual machine in a simple configuration file, and Vagrant creates the same Virtual machine using just one simple command. It provides command-line interfaces to automate such tasks.
How To Install and Use Vagrant on Debian 11
To install Vagrant on your server, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article about the Initial Server Setup with Debian 11.
Also, you need to install VirtualBox on your server. For this, you can check our article How To Install VirtualBox on Debian 11.
Now follow the steps below to install Vagrant on Debian 11.
Installing Vagrant on Debian 11
You can install Vagrant in the latest version as a deb file from the Vagrant official site.
To check the latest version of Vagrant, you can visit the Vagrant downloads page.
First, download the Vagrant package by using the curl command, just remember to replace the version that you have checked in the following command:
curl -O https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_x86_64.deb
When your download is completed, update your local package index with the following command:
sudo apt update
Then, you can install Vagrant with the following command:
sudo apt install ./vagrant_2.2.19_x86_64.deb
Now you can verify your installation by checking the Vagrant version:
vagrant --version
In your output you will see:
Output
Vagrant 2.2.19
You have successfully installed Vagrant on Debian 11, let’s see how to use it.
Using Vagrant on Debian 11
At this point, we want to show you how to use Vagrant by creating a development environment.
First, you need to create a file that you want to save the Vagrant file there. To do this, run the following command:
mkdir ~/vagrant-project
Then, you need to initialize a new Vagrantfile and specify the box you wish to use on Debian 11.
Boxes are the package format for the Vagrant environments and are provider-specific.
You can check the list of available Vagrant Boxes on the Vagrant Catalog page.
In this example, we want to use the ubuntu/trusty64.
Switch to your Vagrant project directory on Debian 11 with the following command:
cd ~/vagrant-project
Now initialize the Vagrantfile with the following command:
vagrant init ubuntu/trusty64
In your output you will see:
Output
A `Vagrantfile` has been placed in this 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.
You can open the Vagrantfile with your favorite text editor and make changes according to your needs on Debian 11.
Run the following command to create and configure the virtual machine as defined in the Vagrantfile:
vagrant up
Output
==> default: Configuring and enabling network interfaces...
...
Vagrant mounts the project directory at /vagrant in the virtual machine. This allows you to work on the project’s files on your host machine.
You can use the following command to ssh to your virtual machine:
vagrant ssh
Also, you can stop the virtual machine with the command below:
vagrant halt
If you want to stop and destroy all resources that were created during the creation of the machine, you can use the following command:
vagrant destroy
Conclusion
At this point, you learn to set up and use Vagrant on Debian 11.
Hope you enjoy using it.
May these articles on the orcacore website be useful for you: