A crash course
Vagrant is essentially a wrapper around
oracle's virtual box. It provides a nice set
of command line programs that allow you
to do various things with a virtual box, like
starting, stopping, suspending, etc...
It's the glue that makes the magic happen.
Virtualbox is virtualization software that
allows you to run a computer inside your
computer. That virtual machine (or box)
has all the same properties of a normal
computer. It gets an ip address, needs
dedicated resources (that your computer - the host) provides. The operating system
is arbitrary, but windows and linux play
well with virtualbox.
In a typical scenario, the web server that you deploy your websites and applications to will be some flavor of linux. CentOS, Redhat (RHEL), and ubuntu have all become popular options for web servers.
With that in mind, we'll run ubuntu inside of Virtual box, and our web server will live in there. This means no more reliance on wamp, mamp, xampp, etc....
We'll use
to control
which will be
running some flavor of
which will allow us to
install things like
Vagrant
http://www.vagrantup.com
Virtual Box
https://www.virtualbox.org/wiki/Downloads
Putty (windows users)
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Windows Guide:
http://www.sitepoint.com/getting-started-vagrant-windows/
vagrant init ubuntu/trusty64
This command will initialize a new Vagrantfile. Open the newly created Vagrantfile in a text editor of your choice
vagrant up
This command will "spin up" a new box. If your pc does not support virtualization, we'll find out now.
vagrant ssh
This command will login you into the vagrant box via ssh. Windows users may have trouble with this step, that's where PuTTY comes in.
vagrant ssh-config
This command should output the configuration details for ssh so you can ssh into the box via putty.
vagrant suspend
This command will essentially take a snapshot of the machine, and close it down. Restarting the machine with vagrant up will not provision the box (more on this later)
vagrant provision
This command will run any provisioning scripts defined in the Vagrantfile.
vagrant destroy
Completely destroys a box, all state is lost. Doing a vagrant up on this machine will need a reprovision.
Do this now
In order to make this useful, we have to install stuff on the vagrant box (like web servery things, php, mysql, apache, etc...)
git clone git@github.com:ggoforth/bbu
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provision "shell", path: "./scripts/provision.sh"
Magic happens here
Running vagrant up from the root of the bbu project will vagrant up the box, and then provision it for use
This will take a while...
Once it's done, point your browser to:
http://localhost:8080
Vagrant Docs:
https://docs.vagrantup.com/v2
Linux Shell:
http://linuxcommand.org/learning_the_shell.php