Vagrant

Image

Vagrant Local Setup

These instructions assumes:

-Virtualbox installed

-Vagrant installed (if not see https://www.vagrantup.com/docs/)

 

A. Basics: Setting up project directory, network and ports.

  1. Create project directory and then navigate to directory via terminal.

  2. Enter: $ vagrant init precise64 http://files.vagrantup.com/precise64.box

  3. Enter: $ vagrant up

  4. Check installation by logging in with: $ vagrant ssh

  5. Logout with: $ exit OR $ logout

  6. Set up network and ports by opening newly created “Vagrantfile” in project folder. 

  7. In “Vagrantfile” find  and uncommented line “config.vm.network "forwarded_port", guest: 80, host: 8080” (line 25).

  8. Reload new configurations, enter: $ vagrant reload

  9. Start test server to check ports, first login: $ vagrant ssh

  10. Then navigate to server project folder: $ cd /vagrant

  11. Then start simple server: $ sudo python -m SimpleHTTPServer 80

  12. On browser navigate to url: localhost:8080, and should see directory listing of /vagrant

  13. Stop server to proceed with further provisioning $ vagrant halt OR $ vagrant suspend OR $ vagrant destroy (destroy is a bit extreme)

 

B. Apache: manual setup

  1. Start or restart vagrant: $ vagrant up OR $ vagrant reload

  2. Get update: $ sudo apt-get update

  3. Install apache: $ sudo apt-get install apache2

  4. Say yes to everything

  5. Setup symlink from apache’s default hosting dir /var/www to vagrant project dir. /vagrant: 

    $ sudo rm -rf /var/www

    $ sudo ln -fs /vagrant /var/www

 

  1. Exit ssh: $logout

  2. Create test index file: $ echo “<h1>Hello World</h1>” > index.html

  3. Got to localhost:8080 and check results.