A complete guide to setup vagrant on Ubuntu 18.04
Start by importing GPG keys of the Oracle Virtualbox repository:
Both commands should output OK which means that keys are successfully imported and packages from this repository are trusted.
Next add virtual box APT repository:
sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"
$(lsb_release -cs) will print the Ubuntu codename. For example, if you have Ubuntu version 18.04 the command will print bionic.
If you get an error message saying add-apt-repository command not found then you need to install the software-properties-common package.
Once the Virtualbox repository is enabled, update the apt package list and install the latest version of Virtualbox:
Now Virtualbox is installed on your Ubuntu system, start:
update package list:
Download the Vagrant package:
if curl is not installed :
Now try to download the Vagrant package again
Once the .deb file is downloaded, install it:
Verify Vagrant installation:
The output should be similar to
Getting Started with Vagrant
Now Vagrant is installed on your Ubuntu system let's create a development environment.
The first step is to create root directory for project which will contain Vagrantfile file. Vagrantfile is a Ruby file that contain configurations and provision the virtual machine.
Next initialize a new Vagrantfile (will create vagrant file):
and specify the box you want to use.
(You can search other boxes on this link https://app.vagrantup.com/boxes/search we’ll use ubuntu/trusty64)
Now create and configure the virtual machine as specified in the Vagrantfile:
Next update changes in Vagrantfile:
Next reload vagrant and virtual box:
To ssh into the virtual machine:
Can stop the virtual machine:
Can destroys all resources(be careful):