Managing a Headless VirtualBox Installation with phpvirtualbox (Ubuntu 16.04 LTS)

Managing a Headless VirtualBox Installation with phpvirtualbox (Ubuntu 16.04 LTS)

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 (like in the tutorial VBoxHeadless – Running Virtual Machines with VirtualBox 5.1 on a headless Ubuntu 16.04 LTS Server). This tutorial explains how to install phpVirtualBox on an Ubuntu 16.04 server to manage a locally installed, headless VirtualBox.eval(ez_write_tag([[728,90],’howtoforge_com-box-3′,’ezslot_5′,106,’0′,’0′]));

eval(ez_write_tag([[580,400],’howtoforge_com-medrectangle-3′,’ezslot_2′,121,’0′,’0′]));

1 Preliminary Note

I’m assuming that a headless VirtualBox is already installed on the local Ubuntu 16.04 server, e.g. as described in the tutorial VBoxHeadless – Running Virtual Machines with VirtualBox 5.1 on a headless Ubuntu 16.04 LTS Server.

I’m running all the steps in this tutorial with root privileges, so make sure you’re logged in as root:

sudo su

 

2 Installing phpVirtualBox

First, create a system user called vbox and add it to the vboxusers group:

useradd -m vbox -G vboxusers

Create a password for the vbox user:

passwd vbox

Create the file /etc/default/virtualbox and put the line VBOXWEB_USER=vbox in it (so that the VirtualBox SOAP API which is called vboxwebsrv runs as the user vbox):

nano /etc/default/virtualbox
VBOXWEB_USER=vbox

Next create the system startup links for vboxwebsrv and start it:

systemctl enable vboxweb-service
systemctl start vboxweb-service

We need a web server with PHP support to serve phpVirtualBox – I’m using Apache2 here. Install Apache and PHP as follows:eval(ez_write_tag([[580,400],’howtoforge_com-medrectangle-4′,’ezslot_1′,108,’0′,’0′]));

apt-get -y install apache2 libapache2-mod-php7.0 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libapr1 php7.0-common php7.0-mysql php7.0-soap php-pear wget

Restart Apache:

systemctl restart apache2.service

I want to serve phpVirtualBox from Apache’s default virtual host with the document root /var/www/html (I will install it in /var/www/html/phpvirtualbox) – if you have a different document root, you must adjust the following steps:

cd /var/www/html
wget http://downloads.sourceforge.net/project/phpvirtualbox/phpvirtualbox-5.0-5.zip

Unzip phpVirtualBox and rename the phpvirtualbox-5.0-5 to phpvirtualbox for ease of use:

unzip phpvirtualbox-5.0-5.zip
mv phpvirtualbox-5.0-5 phpvirtualbox

Next go to the /var/www/phpvirtualbox/ directory…

cd /var/www/html/phpvirtualbox/

… and create the file config.php by copying it from config.php-example:

cp config.php-example config.php

Open config.php and fill in the password you created earlier for the vbox system user:

nano config.php
[...]
/* Username / Password for system user that runs VirtualBox */
var $username = 'vbox';
var $password = 'secret';
[...]

That’s it already – you can now open a browser and access phpVirtualBox as follows:

http://www.example.com/phpvirtualbox/

or By IP:

http://192.168.1.100/phpvirtualbox/
About the Author

Leave a Reply