Here are my notes on installing phpVirtualBox, a webbased graphical interface for VirtualBox, now recommended from VirtualBox’s site! These notes are for Debian 8.2 using Apache.

The web interface looks very similar to the original VirtualBox GUI and works very well.

phpVirtualBox01

If you haven’t done so already install Apache and php5:

# aptitude install apache2 php5

Installing VirtualBox
Source: https://www.virtualbox.org/wiki/Linux_Downloads

Add the following line to your /etc/apt/sources.list:

deb http://download.virtualbox.org/virtualbox/debian jessie contrib

(If you’re using an other version of Debian change jessie to your version.)

Add Oracle VirtualBox’s keyfile to your system so the source is trusted. (Don’t do it if you don’t want automatic updates for VirtualBox.)

# wget https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | apt-key add -
# aptitude update
# aptitude install virtualbox-5.1 

Install the Extension Pack (check here which version is the current one first):

# wget http://download.virtualbox.org/virtualbox/5.0.10/Oracle_VM_VirtualBox_Extension_Pack-5.0.10-104061.vbox-extpack
# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.0.10-104061.vbox-extpack

Set up your system
Create a dedicated VirtualBox user and create a password:

# useradd -d /home/vbox -m -g vboxusers -s /bin/bash vbox
# passwd vbox

You’ll need the password later on.

Tell your system which user is going to run VirtualBox. In /etc/default/virtualbox (create it if it doesn’t exist):

VBOXWEB_USER=vbox
VBOXWEB_HOST=127.0.0.1

VirtualBox has a web interface for just this kind of software. We’ll be running it as our vbox user because it doesn’t need access to the rest of your system.

# sudo -u vbox vboxwebsrv &

The ampersand at the end detaches the program from the console so if it’s running and you press Ctrl+C it won’t stop but you will be able to do other stuff in that console including closing it.

If VirtualBox is running on another server you must pass along its IP address here:

# sudo -u vbox vboxwebsrv -H 192.168.1.4 &

Have vboxweb-service start on boot so we don’t need to enter the command manually every time:
in /etc/init.d/vboxweb (create it):

#!/bin/bash
sudo -u vbox vboxwebsrv &

Make the script executable:

# chmod +x vboxweb

Tell Debian to run it at normal bootups:

update-rc.d vboxweb defaults

The remarks about the script being incomplete is expected. Feel free to improve it.

Reboot to see if it works.

Installing phpVirtualBox
Download phpVirtualBox and extract it as a subfolder of /var/www/html. For production machines place phpVirtualBox in its own directory and restrict access.

# aptitude install unzip
# cd /var/www/html
# wget http://sourceforge.net/projects/phpvirtualbox/files/latest/download -O phpvirtualbox.zip

Unzip the downloaded file:

# unzip phpvirtualbox.zip

Rename for easier access:

# mv phpvirtualbox-5.0-3/ phpvirtualbox

Copy the config file and edit it:

# cd /var/www/html/phpvirtualbox/
# cp config.php-example config.php

In /var/www/html/phpvirtualbox/config.php change:

var $username = 'vbox';
var $password = 'P@55w0rd';

Use the password you gave the vbox user earlier on.

Open your browser and point it to your server’s address followed by /phpvirtualbox, for example http://myserver/phpvirtualbox. Default username and password are both admin.

To view the VM, select it and on the right side click the Console button. If all is well you will be able to select your desired screen resolution and connect to the VM.

phpVirtualBox08

Pretty cool!

The part that provides this is actually an RDP client embedded in the VirtualBox Extention Pack. If it doesn’t work make sure you have the latest Extension Pack installed.

It is also possible (and faster) to view the VM from a locally installed RDP client.

If you’re on a Windows system just run

C:\>mstsc

or type remote desktop in the Start Menu box.

phpVirtualBox05

In the Remote Desktop Connection window type the IP address of the server hosting VirtualBox (not the address of your virtual machine) followed by the port number.

phpVirtualBox04

The port number defaults to 9000 but you can set it from the virtual machine’s properties in VirtualBox: Display > Remote Display.

phpVirtualBox06

A port or port range is accepted.

If unsure just check what the built-in console wants to connect to:

phpVirtualBox07

Remote Desktop will then show your virtual machine.

phpVirtualBox03

Alternatively select the VM in phpVirtualBox and from the Details window, under Display, click on the port number. This will fire up your RDP client.

There are terminal services clients for just about any operating system.

Notes:
– phpVirtualBox’s default username and password are both admin.

– VirtualBox’s default interface and phpVirtualBox even more so do not show all options. If you need to perform an operation on a VM that requires options not shown in the GUIs use the command line interface: VBoxManage. Its documentation is excellent and it allows you to access all available options.

– If you use VBoxManage remember to do it under the account of your dedicated VM user (c.q. vbox). If you use root or any other account not in /var/www/phpvirtualbox/config.php the operations will not be reflected in the web interface.

– phpVirtualBox major and minor versions always reflect VirtualBox versions.

– A very cool feature is remote usb. You can pass your usb device through to the VM via the remote display. Haven’t tested it yet but I will. Read all about it here!

– If you’re planning on running PfSense like I did or just *BSD check out this post on fixing a high CPU load.

If you’re looking for a VirtualBox backup script, you’re in luck!

Enjoy!