Saturday, November 10, 2018

Start using Vagrant, now!

Hi there,
If you are a web developer, and your terminal is Windows machine.
I am sure you must have faced many hurdles in your development tasks, as most of web hosting servers are Linux based. And doing development on windows, testing deploying on Linux may raise bugs due to environmental differences.

So its best to have development environment, similar to your UAT and Prod environment.

This leaves you with several options.

  1. Get hosted linux server - good option but price can be issue for some of us.
  2. Get a separate machine to run linux and use it as dev env.
  3. Install VM ware, Virtual box and manually manage VMs on your windows terminal.
  4. Use Vagrant.
So we will jump directly to option number 4, i.e. using Vagrant.


Well I will not waste any time by giving exact definition what exactly is vagrant, for that please click here.

In simple words, Vagrant provides you ready boxes to create VMs on your local machine.
Once you install Vagrant, it installs virtual box as well. In case you want to increase resources on your VM, you need to tweak same on Virtual box config.

So why its good as compare to managing VMs?

  • Installing VMs will take time, on Vagrant it just takes time on first as process downloads vagrant box. (vagrant box is equivalent to iso).
  • Creating deleting vms takes hardly minute.
Here is my sample config to create Lamp vagrant, though you can get direct lamp vagrant box ready, but I prefer to build it myself.

Vagrant.configure("2") do |config|
  config.vm.define :lamp do |lamp|
    lamp.vm.box = "ubuntu/bionic64"
    lamp.vm.network "forwarded_port", guest: 3306, host: 8306, protocol: "tcp"
lamp.vm.network "forwarded_port", guest: 80, host: 8380, protocol: "tcp"
    lamp.vm.hostname = "lamp"
lamp.vm.synced_folder "local/", "/home/jthakar/local"
  end
end


That's all for this post.

No comments:

Post a Comment

Installing ruby on rails with Apache on Ubuntu 16.04 LTS for production

Recently I decided to start with ROR and move away from PHP. So I decided to first setup production like environment for rails. And to my...