My Vagrant & Ansible setup
This creates my super-sexy dev environment in a resusable way, in the form of a Vagrant VM.
The VM runs Ubuntu 14.04 LTS and comes with the following:
- Apache 2.4
- PHP 5.6.6
- MySQL 5.6
Credit to Phansible for the initial box that I built upon.
Virtual hosts are set up in a snazzy way:
Creating a folder in the
www folder "creates" a vhost with the
.vg (for VaGrant) TLD. The docroot will be
public_html under that folder.
For example, creating the following folder structure:
Will allow you to visit kieranajp.vg. No config required beyond the initial setup.
This does of course depend on you pointing that domain to the VM's IP address (192.168.33.99).
This is only tested on Mac OS X right now, but I'm pretty sure it'll work on Linux and have plans to get it working on Windows too.
- Make sure you have Vagrant, VirtualBox and Ansible installed
- Clone this down
vagrant upand wait for it to provision stuff.
- Either manually edit your
/etc/hostsor use something like
dnsmasqto point the
.vgTLD to 192.168.33.99
- To do this,
brew install dnsmasqand follow Homebrew's instructions post-install
- You should now be able to
dig anything.vgand get a valid response back.
- To do this,
- If you want to be able to
vagrant upwithout running sudo, then run
sudo ./vagrant-sudoers.shto add
This setup now allows you to create the aforementioned folder structure inside the provided
www folder and just visit its URL in your browser. Zero config required, you should never have to touch a terminal window.
If you do have an aversion to the terminal entirely, then I recommend Vagrant Manager, which will allow you to boot your VM from a GUI. After the initial setup you should never have to touch a terminal window again!
Something something threadsafe when I try and run the vagrant box for the first time!
SSH into the vagrant box and replace the
mpm_event symlinks with symlinks to
mpm_prefork instead - or just
a2dismod mpm_event && a2enmod mpm_prefork (as root)
I need node.js and npm installed
The best way is to use NVM
I need to change the TLD that's used (from .vg to something else - for example .dev)
On the host, edit
/usr/local/etc/dnsmasq.conf and add
address=/dev/192.168.33.99, then create
On the virtual machine, edit
/etc/apache2/sites-enabled/000-default.conf and replace all instances of
dev (there should be two). Then restart Apache (with
sudo apachectl restart).
To change this in the Ansible scripts before you provision the VM, edit
roles/apache/templates/vhost24.conf.tpl in this repo (note that this canonical version of the repo will remain using
I don't have CURL / mcrypt / memcached!
sudo apt-get install php5-curl php5-mcrypt memcached php5-memcached
The Vagrant box ran out of RAM! Increase its RAM value in the
vagrant reload and try again.