3

I'd like to ask some information about Vagrant.

First things first, my PC runs Windows as the main OS, I'm using VirtualBox and I've installed VirtualBox in which I've created a virtual where I've installed Ubuntu and set up my development environement (Ruby-MySQL-Git-Nodejs etc), but I'd like to see whether is better option to switch to Vagrant or keep things as currently are.

Now, regarding Vagrant. From a little research I've done about why using Vagrant most resources say that it gives you the ability to create a virtual development environment same as the production. Also, by installing Vagrant you can set up a virtual Linux environment on every OS either Windows, or Mac or Linux too.

So far so good but my main question is can I use Vagrant for creating multiple development environments? so for example:

  1. Have n-different development environments: A for Ruby (Ruby - Rails - Postgres - Git - Nodejs) and B for PHP (PHP-MySQL-Git). So if you try in B the ruby -v or node -v commands they won't be identified as installed in this one.
  2. Usually on a development environment there's a folder where we keep all projects, like projects/project-a, projects/project-b, projects/project-c etc etc. Can I have different/separate environements for each project, even if both project-a and project-b are PHP projects? So basically I want to keep them separate and clean from each other to avoid any mess and conflicts.

1 Answer 1

2

Yes! I love Vagrant even though it doesn't do much, but it makes it convenient. Just keep a Vagrantfile in each of your project-a... folders and they will be separate machines. You can have ones for Rails, for PHP, etc.

Here are existing ones for Rails: https://atlas.hashicorp.com/boxes/search?utf8=%E2%9C%93&sort=&provider=&q=rails

For PHP: https://atlas.hashicorp.com/boxes/search?utf8=%E2%9C%93&sort=&provider=&q=php

To bring up a dev environment (presumably with server), just type

vagrant init leopard/rwtrusty64
vagrant up
vagrant ssh

Super simple and reproducible. Check the docs for more. https://www.vagrantup.com/docs/vagrantfile/

Even better, you can install Vagrant and VirtualBox with Chocolatey, just like yum or apt-get or emerge.

chocolatey install virtualbox
chocolatey install vagrant
2
  • Is it better to have Linux as my main OS, or works exactly same no matter what the main OS is? Also can I set it up on my (virtual machine) Ubuntu os so I can have all dev environments there?
    – user517862
    Apr 6, 2017 at 20:59
  • It works the same no matter the main OS. That's the benefit. If you have a virtual machine inside a virtual machine, that will get complicated, slower, and have possible problems. I'm sure it's possible, but not sure if VirtualBox can do that - have not tried.
    – Chloe
    Apr 7, 2017 at 0:07

You must log in to answer this question.