Last updated 30 October 2010. Created on 5 May 2009.
Edited by midkemia, doka. Log in to edit this page.

With some scripting on Ubuntu 9.04 (Jaunty Jackalope) we can build fully customized Drupal LAMP development servers, as virtual appliance to VMware, or to other virtualization environments like XEN or KVM. In this how-to, you can learn how to use this method to have various development or test servers in one hardware box running Ubuntu 9.04 and VMware Server 2.0.1.

You need a machine with Ubuntu 9.04 (Jaunty Jackalope) and VMware Server 2.0.1, as host system to the appliances. VMware Server 2.0.1 install on Ubuntu 9.04 can be learned here or here. We will need free IP addresses for the virtual machines, so you will need a properly configured DHCP server or a router, as well.

vmbuilder
The magic happens with vmbuilder, a tool introduced in Ubuntu 8.10, and targeted to build virtual machines with Ubuntu as operating system for multiple virtualization environments. Currently it supports Xen, KVM, VMware Workstation 6, and VMware Server. In the following, we are going to create virtual appliances to VMware Server.

To install vmbuilder, type:
sudo apt-get install python-vm-builder

To learn the parameters for Ubuntu and VMware Server, type:
sudo vmbuilder vmserver ubuntu --help

Defining the Drupal LAMP virtual machine
Defining a virtual machine with Ubuntu's vmbuilder is quite simple, there is set of command line parameters, but here we use a configuration file. So at the end, we'll create a Drupal LAMP server with Ubuntu for VMware with this simple command:
vmbuilder vmserver ubuntu -c lamp-vm.cfg

The content of lamp-vm.cfg file is:

##
## config file for vmbuilder
##
## use: sudo vmbuilder vmserver ubuntu -c lamp-vm.cfg
##
## background: http://www.wepoca.net/
##
## created by doka@wepoca.net
## 2009-05-04
## www.wepoca.net
##

[DEFAULT]
arch = i386
overwrite = true
tmpfs = -
firstboot = vm-boot.sh
mem = 1024
hostname = drupal
domain = local
ip = 192.168.0.2
user = doka
name = Doka
pass = wepoca

[ubuntu]
flavour = virtual
suite = jaunty
mirror = http://192.168.2.31:9999/ubuntu
components = main,universe,restricted,multiverse
addpkg = acpid, wget, nano

[vmserver]

Most probably you have to understand and change the parameters above, so in order to understand the parameter, please refer to https://help.ubuntu.com/community/JeOSVMBuilder

lamp-vm-boot.sh: the booting script
In this script we set the locale to hu_HU, make update&upgrade in order to finish the installation, install the OpenSSH server, and clean up after install. Before use, you might want to set the locale to your preferences.

##
## This script will run the first time the virtual machine boots
## It is ran as root.
##
## use: called by lamp-vm.cfg
##      
##
## background: http://www.wepoca.net
##
## created by doka@wepoca.net
##            2009-05-04
##            www.wepoca.net
##
# Expire the user account
passwd -e doka

# Install openssh-server
apt-get update
apt-get install -qqy --force-yes openssh-server

# Intstall drupal 6 and the complete LAMP stack
apt-get install drupal6

#install and configure phpmyadmin
apt-get install phpmyadmin

# PHP memory increase to 64M
sed -i 's/memory_limit = 16M/memory_limit = 64M/' /etc/php5/apache2/php.ini

# correct some errors in drupal6 package
# 1. enable mod_rewrite in Apache2
a2enmod rewrite
/etc/init.d/apache2 restart
# 2. set the correct base URL in htaccess
sed -i 's/# RewriteBase \/drupal/ RewriteBase \/drupal6/' /etc/drupal/6/htaccess

# clean up
apt-get autoclean
apt-get autoremove


# display info for first login
#
# the first user from config file
USER=`ls /home | grep -v 'lost+found'`
#
# actual IP
IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }'`
#
echo ""
echo ""
echo "Your virtual machine has been booted!"
echo "Copy/paste next line into a terminal, and login to the new virtual machine!"
echo "ssh $USER@$IP/drupal6/install.php"
echo ""

Accelerate the install process

  1. Using Ubuntu local mirror
  2. On your host you can install and config apt-proxy. It caches the apt packages, so do not have to download in each and every cases. Useful manual is here: https://help.ubuntu.com/community/AptProxy

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.