Virtualbox Headless Server

Creating virtual machines is easy on a workstation with a nice gui interface, but what about if you want to do this on a server install that has nothing but a command line. This tutorial goes over installing a headless Ubuntu 10.04 server with phpvirtualbox to manage your virtual machines. From start to finish the set up takes about a hour to complete. The following are the steps I took to complete the install, most came from the documentation for phpvirtualbox.

Start off by adding the Virtualbox repository to /etc/apt/sources.list
echo "deb http://download.virtualbox.org/virtualbox/debian lucid contrib non-free" | sudo tee -a /etc/apt/sources.list

Add the Virtualbox repository key
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -- | sudo apt-key add oracle_vbox.asc

Update Ubuntu
sudo apt-get update && sudo apt-get -y upgrade

Now we need to install Virtualbox, Apache2, PHP5, Unzip and OpenSSH server.
sudo apt-get -y install virtualbox-4.0 apache2 php5 libapache2-mod-php5 unzip openssh-server

Apache2 is the web server that will run phpVirtualBox.
PHP5 is the programming language that phpVirtualBox is written in.
Unzip is to unzip phpVirtualBox after it has downloaded.
OpenSSH server will allow you to manage the server from another workstation. Once this is installed the actual server does not need a monitor, or keyboard.

Create /etc/default/virtualbox
sudo nano /etc/default/virtualbox

Add this one line to the file
VBOXWEB_USER=

Press CTRL+O to write the file to disk
Press Enter to confirm

Add local user to vboxusers group
sudo adduser vboxusers

Now we are ready to download phpvirtualbox.
wget http://phpvirtualbox.googlecode.com/files/phpvirtualbox-4.0-5.zip

Unzip phpvirtualbox
unzip phpvirtualbox-4.0-5.zip

Create the phpvirtualbox directory
sudo mkdir /var/www/phpvirtualbox

Copy the phpvirtualbox files to the folder /var/www/phpvirtualbox. This directory is the default set in Apache2. You can change this in the Apache2 configuration file if you need to, but that is outside of the scope of this. Use the Apache documentation for help - http://httpd.apache.org/.
sudo cp -R phpvirtualbox-4.0-5/* /var/www/phpvirtualbox

Prepare the phpvirtualbox config file
sudo cp /var/www/phpvirtualbox/config.php-example /var/www/phpvirtualbox/config.php

Edit config.php
sudo nano /var/www/phpvirtualbox/config.php

Update the $username and $password variable to match your local user
var $username = ''
var $password = ''

You can now start the Virtualbox web service
sudo /ect/init.d/vboxweb-service start

Download VirtualBox Extension Pack. This package installs what you need to do remote desktop into the virtual machines.
wget http://download.virtualbox.org/virtualbox/4.0.6/Oracle_VM_VirtualBox_Extension_Pack-4.0.6-71344.vbox-extpack

Install VirtualBox Extension Pack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.0.6-71344.vbox-extpack

Restart the server
sudo shutdown -r now

That will create a functional headless server running Virtualbox and phpVirtualbox. Once the server has finished restarting navigate to

http://server_ip_address/phpvirtualbox

Here you will need to use the username admin with the password admin to access the web interface. Once you are logged in you can change the admin password using File > Change Password or create new users under File > Preferences > Users.

In the following screenshots everything you see is in the browser window, except the Terminal Server client. My servers IP address is 192.168.1.110. You will notice that when I RDP to a virtual machine hosted on this server, I use the servers IP address and add a port number. The port number controls which virtual machine I RDP into.

image image image image image image image image image image image image imageimage

Just for reference, the Guest Additions iso is, by default, located at /usr/share/virtualbox/VBoxGuestAdditions.iso.

Built with Jekyll using the KeepItSimple Theme