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.
-
Create project directory and then navigate to directory via terminal.
-
Enter: $ vagrant init precise64 http://files.vagrantup.com/precise64.box
-
Enter: $ vagrant up
-
Check installation by logging in with: $ vagrant ssh
-
Logout with: $ exit OR $ logout
-
Set up network and ports by opening newly created “Vagrantfile” in project folder.
-
In “Vagrantfile” find and uncommented line “config.vm.network "forwarded_port", guest: 80, host: 8080” (line 25).
-
Reload new configurations, enter: $ vagrant reload
-
Start test server to check ports, first login: $ vagrant ssh
-
Then navigate to server project folder: $ cd /vagrant
-
Then start simple server: $ sudo python -m SimpleHTTPServer 80
-
On browser navigate to url: localhost:8080, and should see directory listing of /vagrant
-
Stop server to proceed with further provisioning $ vagrant halt OR $ vagrant suspend OR $ vagrant destroy (destroy is a bit extreme)
B. Apache: manual setup
-
Start or restart vagrant: $ vagrant up OR $ vagrant reload
-
Get update: $ sudo apt-get update
-
Install apache: $ sudo apt-get install apache2
-
Say yes to everything
-
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
-
Exit ssh: $logout
-
Create test index file: $ echo “<h1>Hello World</h1>” > index.html
-
Got to localhost:8080 and check results.