Thomas Venturini
Vagrant - The Basics

Vagrant - The Basics

Using vagrant is very useful and a good practice if you are trying out new stuff and specially if you have to do with servers.

Vagrant is a command line tool to setup and manage virtual hosts from Virtual Box. You can find a lot of these as predefined boxes. There is also a register of boxes where you can look for a setup you could use. Popular ones would be ubuntu/xenial64 or laravel/homestead.

The Goal

In this article we will install Virtual Box, Vagrant and a ubuntu/xenial64 box.


First you need to install Virtual Box.

Now you can install Vagrant.

You should not have any problems with these steps.

Setup your Box

To use Vagrant is super easy, so we will dig right into it. Open a terminal and go to your working directory. Now run the following commands.

mkdir ubuntu-box # create a directory for the box
cd ubuntu-box # go into the directory
vagrant init ubuntu/xenial64 # create a Vagrantfile for your box

If you want you can take a look at the Vagrantfile and modify settings like box name or IP. In this tutorial we won't go through these settings but you can take a look at the documentation if you need further modifications.

Now let's run the actual setup for the box.

vagrant up

This might take a while because vagrant will download the box and run the setup. As soon as the setup is done you can ssh into your new box with the following command.

vagrant ssh

This should log you into your ubuntu/xenial64 vagrant box. You can now install everything you need to do your development or testing. For example you could do some Hello World! examples in PHP and Python 😉


To check the status of your current box you can use the following commands from your host system.

vagrant status # status of the box in current directory
vagrant global-status # all boxes vagrant manages


To start and halt your box you can use the following commands from your host system.

vagrant up # starts the box
vagrant halt # halts the box


To destroy your box you can use the following command from your host system.

vagrant destroy


To connect to your box via ssh and exit out of it when your done, you can use the following commands.

vagrant ssh # ssh into your box from your host system
exit # close your current ssh session and return to your host system


To update the box in your current directory you can use the following command.

vagrant box update # update the current box



For more information you can take a look at the documentation. I would suggest you to check out the provisioning of a vagrant box and then play around with this concept.


I will be using vagrant boxes a lot for my examples so it makes sense to cover the basics in my blog so you can make use of this to. Once setup it is a good practice to develop your applications on a vagrant box.