VirtualBox and Ubuntu 11.10

So I'm switching over from VMWare Server to VirtualBox because, while it works well on Windows, I couldn't get it going on Linux.

VirtualBox has little troublesome setup if you want the same features of VMWare like: web interface and auto-starting VMs. Instructions were a little hard to come by so here they are mashed together for you.

Installing Virtual Box 

This is a simple one. Install the package:
sudo apt-get install VirtualBox-OSE 


Installing the Headless Extension

sudo vi /etc/apt/sources.list
add line:
# Virtual Box Headless
deb oneiric contrib

Download Public Key:
wget -q -O- | sudo apt-key add -

Update and Install
sudo apt-get update
sudo apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.1 dkms

Download Extension Pack from:
Install (Change Pack version to match your downloaded version)
cd ~/Downloads #your download location for the extension pack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.12-77245.vbox-extpack

Create new user that will run Virtualbox and add user to vboxusers group.
sudo adduser virtualbox vboxusers
sudo adduser virtualbox 


Installing Web Interface

For the web interface you need a web server that supports PHP5. You should already have the heavy Apache2 web server installed, if not install it
sudo apt-get install apache2

Add on the PHP5 support and restart Apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart

Download phpvirtualbox from

Extract phpvirtualbox to your web hosting location
cd ~/Downloads #your download location for phpvirtualbox
mkdir /var/www/phpvirtualbox
unzip /var/www/phpvirtualbox/

Rename config.php-example to config.php
mv /var/www/phpvirtualbox/config.php-example /var/www/phpvirtualbox/config.php

Edit the config file
nano /var/www/phpvirtualbox/config.php

Enter the credentials for the virtualbox user you created to run the vboxweb-service earlier.
var $username = ‘virtualbox’;
var $password = ‘plain-text-password’;

Edit the vboxweb-service 
nano /etc/default/virtualbox

Enter the username you for the same user account you created to run the vboxweb-service.

Start the vboxweb-service
/etc/init.d/vboxweb-service start

Now navigate to the web interface

Login with the default credentials:

Change your password by clicking File > Change Password in the web interface


Installing VM Auto-Start

Download VBoxTool from:

Unzip VBoxTool to a new folder vboxtool
cd ~/Downloads #your download location for vboxtool
unzip -d vboxtool

If the version has changed from 0.4 then refer to the readme.txt for the location of the file. The steps below follow the instructions in the 0.4 readme.txt

cd vboxtool/script 
sudo cp vboxtool /usr/local/bin/
sudo chmod +x /usr/local/bin/vboxtool
sudo cp vboxtoolinit /etc/init.d/
sudo chmod +x /etc/init.d/vboxtoolinit
sudo update-rc.d vboxtoolinit defaults 99 10
sudo mkdir /etc/vboxtool

Create empty config files
sudo touch /etc/vboxtool/machines.conf
sudo touch /etc/vboxtool/vboxtool.conf

Now you can add your VM(s) to the list of VM(s) to start up by editing the /etc/vboxtool/machines.conf file.

For Example, to start a VM named tristan and override its  VRDP port add the following line to machines.conf
To start the VM type:
vboxtool start "tristan"
To start all configured VMs:
vboxtool autostart