Vagrant

From Logic Wiki
Jump to: navigation, search


https://www.youtube.com/watch?v=PmOMc4zfCSw

https://www.vagrantup.com


Let's install Vagrant

Install VirtualBox: https://www.virtualbox.org/
Install Vagrant: http://vagrantup.com/

Select a Vagrant Box from https://vagrantcloud.com

  1. add it to your list of boxes
vagrant box add hashicorp/precise32
  1. create a new folder for your project & init vagrant
vagrant init hashicorp/precise32
  1. run your new machine
vagrant up
  1. ssh into your new machine
vagrant ssh

Now you are connected to a new machine!

hit exit to disconnect

Let's make this feel like the real world by adding a fake domain name

open the Vagrantfile and uncomment the private_network line & change to your desired IP config.vm.network "private_network", ip: "22.22.22.22"

run vagrant reload

make a fake domain for that ip

run

sudo open /etc/hosts -a "Sublime Text" to open your /etc/hosts file in Sublime Text

add this line to the end of the file and save 22.22.22.22 mytestsite.com

Nice! Now going to mytestsite.com will connect to our machine!

Let's install nginx so we can see if our "domain" is working

  1. always update apt-get on a new machine
sudo apt-get update
  1. install nginx
sudo apt-get install nginx
  1. start-er up
sudo service nginx start

Now, go to mytestsite.com...you should see Welcome to nginx!