Vagrant

Up to date getting started page

https://www.vagrantup.com/intro/getting-started/index.html

Vagrant boxes

https://app.vagrantup.com/boxes/search

Quickstart

$ mkdir vagrant_getting_started
$ cd vagrant_getting_started
$ vagrant init
$ vagrant box add hashicorp/precise64
Edit the Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
end
$ vagrant up
$ vagrant ssh
$ vagrant@precise64:~$ logout
Connection to 127.0.0.1 closed.
$ vagrant suspend
$ vagrant halt
$ vagrant destroy
$vagrant remove
Sync between Host and Guest
vagrant@precise64:~$ ls /vagrant
Vagrantfile
Provisioning - create and edit bootstrap.sh file
#!/usr/bin/env bash

apt-get update
apt-get install -y apache2
if ! [ -L /var/www ]; then
  rm -rf /var/www
  ln -fs /vagrant /var/www
fi

Edit the Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.provision :shell, path: "bootstrap.sh"
end
$ vagrant reload --provision
$ vagrant ssh
...
vagrant@precise64:~$ wget -qO- 127.0.0.1
Setup Port Forwarding (forwards ports from Host to machine)
Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.provision :shell, path: "bootstrap.sh"
  config.vm.network :forwarded_port, guest: 80, host: 4567
end

load http://127.0.0.1:4567 in host browser
vagrant up --provider=vmware_fusion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.