Setting up virtual host

You need to edit your /etc/hosts file so that http://foo resolves to 127.0.0.1.

Edit the file /etc/hosts (with sudo/root) and add the following line:

127.0.0.1 foo

Checkout https://github.com/Aslamkv/vh :)

This tool lets you add and remove virtualhost in Ubuntu by doing every configuration for you. It is simple and easy to use.

Disclaimer: I am the author :P