Download latest Ubuntu server
Create a new virtualmachine with virtualbox i used the name 'devbox_ubuntu'
Boot your virtualmachine and install the needed packages for chef/vagrant
$ sudo bash
$ apt-get install sudo ruby ruby-dev libopenssl-ruby rdoc ri irb build-essential ssl-cert curl rubygems puppet
$ echo “deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main” tee /etc/apt/sources.list.d/opscode.list
$ gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
$ gpg --export packages@opscode.com | tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
$ apt-get update
$ apt-get install opscode-keyring chef
fill in none for the URL
Add the vagrant user
$ adduser vagrant
passwrd : vagrant
$ groupadd admin
$ usermod -a -G admin vagrant
Setup sudo for the admin group
$ visudo
%admin ALL=(ALL) NOPASSWD: ALL
Disable DNS for SSHD
$ vi /etc/etc/ssh/sshd_config
UseDNS no
SU to the vagrant user and setup the SSH key
$ su vagrant
$ mkdir -p ~/.ssh
$ chmod 0700 ~/.ssh
$ curl -o ~/.ssh/authorized_keys https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
$ chmod 0600 ~/.ssh/authorized_keys
halt the VM and setup the VM with vagrant on the local machine
$ vagrant package --base devbox_ubuntu
$ mv package.box devbox_ubuntu.box
Wait a while ...
$ vagrant box add devbox_ubuntu devbox_ubuntu.box
$ mkdir devbox_ubuntu && cd devbox_ubuntu
$ vagrant init devbox_ubuntu
$ vagrant up
[default] Importing base box 'devbox_ubuntu'... .... lots of output
Do a test SSH login to see if it all works
$ vagrant ssh
$ exit
$ vagrant halt
$ vagrant destroy
Cool. So that's all there. Now setup some recipes (apache2 and dotdeb php 5.4)
$ mkdir cookbooks
$ cd cookbooks
$ git clone https://github.com/opscode-cookbooks/apache2
$ git clone https://github.com/tlenss/misc.git
$ mv misc/chef/cookbooks/dotdeb .
$ rm -rf misc
Setup the recipes in the Vagrantfile
$ cd ..
$ vi Vagrantfile
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe("dotdeb")
chef.add_recipe("dotdeb::php54")
chef.add_recipe("apache2");
chef.add_recipe("apache2::mod_php5");
end
Boot the VM again and let chef do it's thing. Once done. Login and verify the PHP version
$ vagrant up
$ vagrant ssh
$ php -v
PHP 5.4.17-1~dotdeb.0 (cli) (built: Jul 6 2013 17:53:27)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
I used a modified dotdeb cookbook by Yevgeniy Viktorov. And wrote a small article about it a while back. It might be helpful!
Adding additional PHP extensions i use the chef's standard PHP recipes from https://github.com/opscode-cookbooks/php. Apparently Ubuntu and dotdeb's PHP 5.4 have a dependency issue with libmysqlclient. Using mysqlnd instead of mysql should fix this