Installing a PHP web interface for Virtual Box: phpVirtualBox[17 Sep 2010]

Tested on:

  • Debian Stable Lenny 5.0
  • kernel: 2.6.26-2-686
  • Virtual Box version: 3.2.8
  • webserver: Apache2
  • PHP5

Setup the webserver

Install apache2 and PHP support, as root.

# apt-get install apache2 php5 libapache2-mod-php5

Install Virtual Box

You can get all the official guides from here  http://www.virtualbox.org or do as follows (as root):

  1. add vbox repository uri
    # echo "deb http://download.virtualbox.org/virtualbox/debian lenny non-free" >> /etc/sources.list
    
  2. add oracle public key
    # apt-get install apt-key
    # wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
    
  3. install Virtual Box 3.2
    # apt-get update
    # apt-get install virtaulbox-3.2
    

Install phpVirtualBox

  1. First move to your webserver root directory. In my case /srv/www (Debian users should have /var/www as apache root directory).
    Make a directory like "phpvirtualbox".
    # mkdir phpvirtualbox && cd phpvirtualbox
    
  2. Now donwload the latest phpVirtualBox release here. You can check it at  http://code.google.com/p/phpvirtualbox/downloads/detail?name=phpvirtualbox-0.5.zip&can=2&q= . Today the latest is ver 0.5 and I can use wget to download it.
    # wget http://phpvirtualbox.googlecode.com/files/phpvirtualbox-0.5.zip
    
  3. Unzip the file
    # unzip phpvirtualbox-0.5.zip
    
  4. Set the webserver user as owner of all this stuff. Debian users will know that www-data is the default apache user.
    # cd .. && chown www-data\: phpvirtualbox
    

Create vbox user

Last, you have to create a user who will run the Virtual Box web service.

# adduser vbox --no-create-home --ingroup vboxusers

Set up a simple password like vbox.

In place of that you can also add your user to vboxusers group and run the service with it.

Change phpVirtualBox configuration

Change directory to your unzipped one (phpvirtualbox-0.5). Use your favorite editor to modify the config.php file placed here.

# joe config.php

I like joe ;)

Now be sure that:

  • line: var $username = 'vbox'; where vbox is the user you created above;
  • line: var $password = 'vbox'; where vbox is the password for vbox user setted before;
  • line: var $location = 'http://localhost:18083'; is exactly this entry.


If you setted an existing user into vboxusers group in place of create a new vbox user, be sure to fill username and password with the right information.

Run the service

Login as vbox user.

# su vbox

Run the service!

$ vboxwebsrv

Now connecting to http://yourhost/phpVirtualBox/phpvirtualbox-0.5/ you can access your new Virtual Box web consolle! Have fun!