A recipe for building a development VM for working on Laravel and apps.
Vagrant uses Ansible on your host machine to provison, but installs it on the guest machine if your host is running Windows. For Linux, OS X, others:
sudo pip install ansible
I strongly recommend using this Vagrant plugin that makes sure your VirtualBox guest additions are up-to-date. If you have issues when bringing your VM down and back up again this can help.
To add your app to the virtual machine, open Vagrantfile and edit line 8 ("Add your Laravel app here") with the relative path to your app on your local (host) machine. For example, I submodule this repository into my applications and then reference one level above:
git submodule add https://github.com/rmasters/laravel-ansible vm
# Add your Laravel app here
#config.vm.synced_folder "../", "/srv/app"
To boot your VM:
vagrant up
# If provisioning doesn't happen, run
vagrant provision
# You should see [default] Running provisioner: ansible...
The following ports are exposed:
You can change these ports in your Vagrantfile. Vagrant may reassign them if they are already in use.
Connect to the following services in your app or by using clients on your host
by tunnelling through SSH (run vagrant ssh-config
to find which local port):
To tunnel through SSH use the username vagrant and the SSH key in ~/.vagrant.d/insecure_private_key.