phpvirtualbox - Running Virtual Machines With VirtualBox 4.2 and phpvirtualbox On A Headless Ubuntu 12.04 Server

Author: Luis Rodriguez<luis [at] techreanimate[dot] com>

phpvirtualbox is a web-based VirtualBox front-end written in PHP that allows you to access and control remote VirtualBox instances. It tries to resemble the VirtualBox GUI as much as possible to make work with it as easy as possible. It is a nice replacement for the VirtualBox GUI if you run VirtualBox in headless servers. This tutorial explains how to install phpvirtualbox on an Ubuntu 12.04 server to manage a locally installed, headless VirtualBox (version 4.2).

 

1 Preliminary Note

I have tested this on an Ubuntu 12.04 server (host system) with the IP address 192.168.0.100 where I'm logged in as root.

Run:

sudo su

 

2 Installing VirtualBox

To install VirtualBox 4.2 on our Ubuntu 12.04 server, we open /etc/apt/sources.list...

nano /etc/apt/sources.list

... and add the following line to it:

[...]
deb http://download.virtualbox.org/virtualbox/debian precise contrib

Then we download the VirtualBox public key...

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -

... and update our package database:

apt-get update

Afterwards, we install VirtualBox 4.2 as follows:

apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.2 dkms

(The dkms package ensures that the VirtualBox host kernel modules are properly updated if the Linux kernel version changes.)

Starting with version 4.0, VirtualBox has introduced so called "extension packs" and has outsourced some functionality like remote desktop connection support (VRDP) that was part of VirtualBox packages before version 4.0 into these extension packs. Because we need remote desktop connections to control our virtual machines, we need to install the appropriate extension pack now. Go to http://www.virtualbox.org/wiki/Downloads, and you will find a link to the following extension pack:

VirtualBox 4.1.18 Oracle VM VirtualBox Extension Pack
Support for USB 2.0 devices, VirtualBox RDP and PXE boot for Intel cards.

Download and install the extension pack as follows:

cd /tmp
wget http://download.virtualbox.org/virtualbox/4.2.12/Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.11-84980.vbox-extpack

(Make sure you grab the latest version from the VirtualBox web site.)

Now we must add the user that will run VirtualBox with password set(vbox in this example) to the vboxusers group:

useradd –d /home/vbox –m vbox

passwd vbox

Type yourpassword twice.

adduser vbox vboxusers

Edit/create virtualbox conf and let's add this user:

nano /etc/default/virtualbox

[...]
VBOXWEB_USER=vbox

Now let’s just make sure the service is in startup:

update-rc.d vboxweb-service defaults

/etc/init.d/vboxweb-service start

Install Apache:

apt-get install apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common apache2 apache2-doc apache2-suexec libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libapr1 php5-common php5-mysql php-pear wget

Download and copy over phpvirtualbox:

cd /tmp
wget https://phpvirtualbox.googlecode.com/files/phpvirtualbox-4.2-4.zip

unzip phpvirtualbox-4.2-4.zip

cp phpvirtualbox-4.2-4 /var/www/phpvirtualbox/

Edit php phpvirtualbox conf file and add the user and password:

nano /var/www/phpvirtualbox/config.php
[...]
var $username = 'vbox';
var $password = 'your vbox password';

Now you can access phpvirtualbox at http://192.168.0.100/phpvirtualbox

This guide was made using https://www.howtoforge.com/vboxheadless-running-virtual-machines-with-virtualbox-4.1-on-a-headless-ubuntu-12.04-server

Share this page:

11 Comment(s)