How To Install Vagrant On Ubuntu 18

Introduction

Vagrant is an open-source tool used to build and manage virtual machine environments. A test environment is required to analyze the latest release and new tools in the market. Vagrant default setting uses VirtualBox to manage the virtualization.

It acts as a key configuration tool to assist in managing multiple virtual environments using the same configuration.

This tutorial will take you through the installation process of Vagrant on Ubuntu 18.04 LTS. We are going to use VirtualBox provider, which is the Vagrant default provider

What is VirtualBox?

You can choose to install two different operating system in a single virtual machine, but you need to restart your system every time you install the system. VirtualBox allows you to run multiple operating systems on a single system. You can switch to any without rebooting your system.

Prerequisites

Before you start, ensure you’re logged in as a root user with sudo privileges.

Installing Vagrant

Start by installing Vagrant on Ubuntu. To do so follow the following steps.

1. Installing VirtualBox

We need to point our virtual machines on VirtualBox. So, to install the VirtualBox package run the command below:

$ sudo apt install virtualbox

2. Installing Vagrant

The next step is to install the Vagrant package from the Ubuntu repositories by running the following command:

$ sudo apt install vagrant

To get the latest stable version for the Vagrant package, go to the Debian package that is found in Vagrant official download page and download it from there.

3. Verifying Vagrant Installation

Once vagrant is installed successfully on Ubuntu, you need to verify the installation by running the command below:

$ vagrant --version

The output should look like this:

Vagrant 2.0.2

Deploying Vagrant On Ubuntu 18.04

After installing Vagrant on your Ubuntu operating system, you need to create and deploy a development environment.

To do so, start by creating the root directory that contains the Vagrantfile file. This is a file that illustrates the configuration and provision process of the virtual machine.

Create the root directory, then switch it with the following:

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

Next, use the vagrant init command to initialize Vagrantfile. Make sure you indicate the box you want to use.

These boxes are Vagrant package format for development environments. To find a full list of the available Vagrant Boxes, go to the Vagrant box catalog page.

In our tutorial, we will use the centos/7 box. To prepare a new Vagrantfile, run the command below:

$ vagrant init centos/7

You should this:

$ 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.

Next, run the vagrant up command to create and configure the virtual machine based on Vagrantfile.

$ vagrant up

The output should look like this:

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

From the results above, it is clear that Vagrant mount the root directory from the project at /vagrant in the virtual machine. This allows the user to work on their files on a host machine.

Run the command below to ssh into the virtual machine:

$ vagrant ssh

To stop your virtual machine, run the command below:

 $ vagrant halt

Running this command should halt the host machine and may destroy all the files that were created before during on your virtual machine:

$ vagrant destroy

Conclusion

Congratulations! You have now installed Vagrant successfully. You can now launch it on your Ubuntu 18.04 machine and start creating a basic development environment within no time.

Check out these top 3 VPS services:

HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
Kamatera
$4.00 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
Hostens
$2.00 /mo
Starting price
Visit Hostens
Rating based on expert review
  • User Friendly
    4.5
  • Support
    3.8
  • Features
    4.3
  • Reliability
    4.5
  • Pricing
    4.8

How To Configure SSH File Transfer Protocol (SFTP) Without Shell Access On Ubuntu 18.04

This tutorial will help you set up SSH File Transfer Protocol to limit SFTP to a
4 min read
David Sierra
David Sierra
Hosting Expert

How to install and configure Mosquitto MQTT on your Ubuntu 18.04 server?

This tutorial will show you how to install and configure Mosquitto MQTT message
4 min read
David Malcom
David Malcom
Author

How to Install an Ark Server On an Ubuntu 18.04 VPS or Dedicated Server

How to setup a dedicated Ark Survival Evolved Multiplayer server on Ubuntu 18.04
3 min read
Mark Armistead
Mark Armistead
Author

How to Setup Vanilla Forum on Ubuntu 18.04 Server

Vanilla Forum powers thousands of discussions on the internet today. it is built
4 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.