Additionally to my fully functional development environment described here, I want to have some more programs.

For example

  • vim
  • composer (global install)
  • php sqlite support

To have these installed automatically, I create a bootstrap.sh file in the same directory like the Vagrantfile.

Here is the content:

#!/usr/bin/env bash

apt-get install vim --yes
apt-get install php5-sqlite --yes
service apache2 restart
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

Then I open the Vagrantfile to add the bootstrap.sh excecution.

config.vm.provision :shell, path: "bootstrap.sh"

In combination with my default setup, my Vagrantfile looks like this:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "avenuefactory/lamp"
  config.vm.network "private_network", ip: "192.168.10.10"
  config.vm.synced_folder "./html", "/var/www/html"
  config.vm.provision :shell, path: "bootstrap.sh"
  
end

Here are more information about provisioning: https://docs.vagrantup.com/v2/getting-started/provisioning.html