phpVirtualBox — Accessing VirtualBox from a Browser

9
14285
VirtualBox on a browser

VirtualBox on a browser

This article introduces phpVirtualBox, an open source, AJAX and PHP-based implementation of the Oracle VirtualBox user interface.

Oracle VirtualBox is great enterprise-ready virtualisation software. However, what it lacks is a powerful Web-based management interface. Usually, people prefer VMWare over VirtualBox, as it has a good Web-based remote management interface.

phpVirtualBox provides an interface that’s a VirtualBox-look-alike for people who are not command-line savvy. Through phpVirtualBox, you can control a headless VirtualBox VM from a Web browser, including operations such as start/stop VMs, take snapshots, configure VMs, import/export VMs, and much more. Some of its code is based on the now inactive VBoxWeb project.

The requirements are:

  • Any Web server with PHP 5.2.0 or later; xampp will be good.
  • A working installation of Oracle VirtualBox 3.2.2 or later.
  • Any Web browser — Firefox, Opera, Chrome or IE — will do the job.

Installation on Windows

Installation is very simple. Here, I’m using Windows XP SP3.

Install Oracle VirtualBox OSE 3.2.10, and then install xampplite-win32-1.7.3. Download phpVirtualBox and extract the files/folder into the htdocs directory. phpVirtualBox requires that vboxwebsrv.exe must be running on the Oracle VirtualBox host machine. This file is located at C:\Program Files\Oracle\VirtualBox\.

Vboxmanage setproperty websrvauthlibrary null
Vboxwebsrv.exe >null

Now, edit the config.php file and change it to the following settings:

/* Username / Password for system user that runs Oracle VirtualBox */
var $username = 'administrator';
var $password = 'guesswhat';
var $location = 'http://localhost:18083/'; 
/*don't change if using single machine for VirtualBox and phpVirtualBox*/

Now navigate to the resulting folder in your Web browser (see Figure 1).

VirtualBox running on Firefox
Figure 1: VirtualBox running on Firefox

Installation on Linux

The installation on Linux is also very simple. I am using Ubuntu 9.10 for this demo, and installed xampp-linux-1.7.3. It comes with the latest PHP version. To install Oracle VirtualBox 3.2 on Ubuntu, first you have to add the repos for VirtualBox in your /etc/apt/sources.list:

deb http://download.virtualbox.org/virtualbox/debian karmic non-free

After that, update your repository cache with the following command:

apt-get update

Now install Oracle VirtualBox:

apt-get install virtualbox-3.2

phpVirtualBox requires you to start the vboxwebsrv program, located under /usr/bin:

su vbox -c '/usr/bin/vboxwebsrv -b -logfile /dev/null>/dev/null'
vbox -- user created to run vboxwebsrv(optional step, you can use your own username)

Here, the parameters are as follows:

  • -b — run program in the background
  • -logfile — log file location for vboxwebsrv

Now download phpVirtualBox:

wget http://phpvirtualbox.googlecode.com/files/phpvirtualbox-0.5.zip

Unpack it to /var/www or /usr/local/apache2/htdocs. In config.php, edit the following parameters:

/* Username / Password for system user that runs Oracle VirtualBox */
var $username = 'administrator';
var $password = 'guesswhat';
var $location = 'http://localhost:18083/'; 
/*don't change if using single machine for VirtualBox and phpVirtualBox*/

Now navigate to the resulting folder in your Web browser.

Pros and cons

Pros: Clutter-free interface for remote management, with all the goodies.

Cons: Intended to run only on a local area network, as it relies on a plain-text password.

Note: For the sake of this demo, I’m using a single physical machine for Oracle VirtualBox and phpVirtualBox. If you don’t want to burden your Oracle VirtualBox installation with a Web server, then you can host phpVirtualBox on another machine. In that case, you have to make some simple modifications, as follows:

In Windows:

Vboxwebsrv.exe -h ip.address.of.virtualbox.host 

/* Username / Password for system user that runs Oracle VirtualBox */
var $username = 'administrator';
var $password = 'guesswhat';
var $location = 'http://ip.address.of.virtualbox.host:18083/'; 
/*don't change if using single machine for VirtualBox and phpVirtualBox*/

In Linux:

su vbox -c '/usr/bin/vboxwebsrv -b -logfile /dev/null -host ip.address.of.virtualbox.host  -port 18083'

Change config.php as for Windows.

9 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here