Joni Junni

Setting up Vagrant on Ubuntu 12.04

Categories: [school]
Tags: [linux], [vagrant], [ubuntu], [linux-project-course], [virtualbox]

Text author: Aleksi Kulmala

Installing Vagrant and Virtualbox

First up when starting this project you have to install Virtualbox first.

You can do it easily from terminal using command:

sudo apt-get install virtualbox

After that you can download the right package for your platform from the Vagrant homepage. You can also install it from command prompt using command:

sudo apt-get install vagrant

When you have installed the package you can go straight to the command prompt. To get Vagrant up and running run these commands:

vagrant init precise http://files.vagrantup.com/precise32.boxvagrant up

Now you have a running virtual machine in Virtualbox. You can connect to it using:

vagrant ssh

Creating a Vagrant project

When you are setting your project up Vagrant has built-in command to get all working first you have to create directory for it:

mkdir vagrant_test
cd vagrant_test
vagrant init

Vagrant uses “boxes” this means you don’t have to build a virtual machine from scratch, instead you use a base images to clone virtual machines. Now we have to add the boxes by using simple command:

vagrant box add precise32 http://files.vagrantup.com/precise32.box

Now that we have done all the setup for the virtual machine we can run a command to start using it

vagrant up

This command will create us a virtual machine running Ubuntu. Now we can log in to it using SSH:

vagrant ssh

Now we have a real virtual machine in our hands and we can do whatever we want with it. If you want to destroy the virtual machine you can run the command:

vagrant destroy

Vagrant has this great feature “synced folders” Vagrant will automatically sync your files to and from the virtual machine.

Sources