Vagrant is a tool to setup reproducible and portable work environments to help maximize the productivity and flexibility of you and your team. You can learn more on the Vagrant website.
Setting up Vagrant and Virtualbox
First of all install Vagrant and VirtualBox on your computer.
Setting up the Ubuntu
We will be using Trusty Tahr 64-bit as our operating system.The easiest way is to use an Ubuntu image available from the Vagrant project team. In the terminal change to the directory where you’ll build your project.
vagrant init ubuntu/trusty64
This will create a vagrantfile in the directory. Open the file using text editor, find the config.vm.network and make the changes as follows.
config.vm.network "forwarded_port", guest: 3000, host: 3000
This will create a forwarded port mapping which allows access to a specific port within the machine from a port on the host machine.Save the file and return back to terminal. You can start the VM with the following:
Now you can ssh into the ubuntu server using:
For windows user if you get a problem executing this command. Make sure you install git and add the path of bin folder (eg. C:\Program Files (x86)\Git\bin ) to path variable.
You are now connected to a fully operational server. Vagrant sets up the /vagrant folder as a shared directory between the virtual machine and your host operating system. You can see all the files from your project folder using:
Making changes in Project files.
To make the changes in the files in the project directory you have two options.
- SSH into your virtual machine and use a text-based editor like Vim or Emacs.
- Run a graphical editor in the host operating system.
Git is a free and open source distributed version control system. If you don’t already have Git, you can install it on Debian/Ubuntu by running:
sudo apt-get install git