Quick and easy setup of a VirtualBox server

In my ever growing home office network I’m always in need of more virtual machines for testing new products. This is why I use DebianVirtualBox and phpVirtualBox to create a quick and easy VirtualBox server.

Here’s a quick rundown to help others set this up quickly.

1. Download a stable version of Debian. Here I am using 7.8.0 Wheezy.

2. Install onto your chosen hardware. During setup simply choose the defaults until you get to set the root password. Make this something secure (obviously!) and then the install asks you to setup a user account. I setup an account named VirtualBox with username ‘vbox’ with password ‘vbox’ (we will use this later).

3. Go through the remaining installation choosing all the defaults until your asked to choose packages. Here you should select just the SSH server, Web server and Standard System utilities. You do not need a Desktop Environment.

4. Reboot the system and login as root. Now some housekeeping, edit the /etc/apt/sources.list and comment out the line that starts with “deb cdrom:” by placing a # at the beginning of the line. This stops the system asking you to put the CD back in anytime you want to install additional software, instead it will be downloaded from the network mirrors.

After saving the file execute:

apt-get update

5. Now we’ll install PHP execute:

apt-get install libapache2-mod-php5 php5

6. Next we’ll install VirtualBox. The latest version available at the time of writing is 4.3.20 so I’m downloading the Debian 64bit version since thats the OS I installed.

wget http://download.virtualbox.org/virtualbox/4.3.20/virtualbox-4.3_4.3.20-96996~Debian~wheezy_amd64.deb

You also should download the extension pack:

wget http://download.virtualbox.org/virtualbox/4.3.20/Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack

Install the deb using

dpkg -i virtualbox-4.3_4.3.20-96996~Debian~wheezy_amd64.deb

You should see a number of errors like

dpkg: dependency problems prevent configuration of virtualbox-4.3:
virtualbox-4.3 depends on libcurl3-gnutls (>= 7.16.2); however:
Package libcurl3-gnutls is not installed.

This is ok, we just fix it using

apt-get -f install

Finally after all that installed, install the VirtualBox extension pack

VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack

7. Now let’s download phpVirtualBox

wget http://sourceforge.net/projects/phpvirtualbox/files/phpvirtualbox-4.3-2.zip

Move to /var/www and unzip

mv phpvirtualbox-4.3-2.zip /var/www
cd /var/www

Then unzip it

unzip phpvirtualbox-4.3-2.zip

But unzip wasn’t found! So install it

apt-get install unzip

Repeat the unzip operation.

Now let’s create a link

ln -s phpvirtualbox-4.3-2 virtualbox

And setup the config

mv config.php-example config.php

Edit the config and set the password for the vbox user changing the line:

var $password = 'pass';

To

var $password = 'vbox';

Finally goto /etc/default and create a file called virtualbox and place the following contents into it

VBOXWEB_USER=vbox
VBOXWEB_HOST=127.0.0.1

And there you have it, all that remains is to start the VirtualBox WebService

service vboxweb-service start

Then connect your browser to http://<host>/virtualbox and enter the default credentials of admin/admin

If you find your only able to create 32 bit virtual machines, its likely that your BIOS has not got virtualization enabled. Reboot and change the BIOS setting to restore 64 bit virtual machines.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>