Build a headless virtualisation server

Use VirtualBox on a headless server to create and manage remote virtual machines that can be accessed from anywhere

Virtual Machine VM qemu

Step 11

Virtual import

You can reuse an older VM from another machine by importing it into VirtualBox on your server. You’ll need to find the relevant machine in the Machines folder in the VirtualBox directory and copy it over to the new directory. Once that’s done, import it like this:

$ VBoxManage registervm Machines/ examplevm/examplevm.xml

Step 12

Headless start

Now we can start the virtual machine from the headless server using the very useful VBoxHeadless tool:

$ VBoxHeadless --startvm “Fedora 17”

This will also start a VRDP service so that you can remotely access the virtual machine from a networked computer.

Virtual Machine VM QEMU
Connect remotely to your VM

Step 13

Remote connect

You’ll notice that the output from the startvm command will comment on what port it’s listening on, in our case 3389. Some RDP clients might automatically see it, but otherwise if you put in the IP address followed by the port into the client, it should pick it up.

Step 14 Headless options

There are some useful VBoxHeadless commands you can use to control the running VM:

$ VBoxManage controlvm “Fedora 17” poweroff
$ VBoxManage controlvm “Fedora 17” pause
$ VBoxManage controlvm “Fedora 17” reset

The commands are fairly straightforward: they power off, pause and reset the VM.

Step 15


While managing a headless server from the command line may be good enough for some, the existence of a graphical, web-based management system is useful for everyone. PHPVirtualBox is exactly that. We need to do some prep before we start, though. Make sure you’re root on your server and add a new user:

$ useradd -m vbox -G vboxusers

Create a password for the new user:

$ passwd vbox

Finally, edit the file at /etc/default/virtualbox and enter the following:


This makes sure that the web interface runs as user vbox.

Step 16

Web server

For PHPVirtualBox, we need a web server that supports PHP. If you don’t already have one set up, you should install Apache 2 and PHP 5 on your system. If you’re using different versions of Apache and PHP, the tutorial will still work, though.

Step 17

Download PHPVirtualBox

Now we can download PHPVirtualBox. Move to /var/www and download the latest version of the file:

$ wget http://phpvirtualbox.

Check the website for the latest version

Step 18

Install PHPVirtualBox

Once downloaded, unzip the software and move it:

$ unzip
$ mv phpvirtualbox-4.1-10 phpvirtualbox

Move to this new directory and then create the config.php file from the example:

$ cp config.php-example config.php

Step 19

Configure PHPVirtualBox

Open up config.php in a text editor and add the details you need for the web server:

/* Username / Password for system user that runs VirtualBox */
var $username = ‘vbox’;
var $password = ‘password’;

Afterwards, restart the server and you should be ready to go.

VM Virtual Machine QEMU
Log In with PHPVirtualBox

Step 20

Log in

To get to your newly installted interface, enter your server’s IP address followed by /phpvirtualbox: for example, From here you’ll need to log in using the default user admin, with the password ‘admin’ as well. Once logged in, you can change this password.

Step 21

Adding VMs

Much like the standard VirtualBox UI, you can add and modify VMs with a series of menus that guide you through creating a hard drive and adding an installation medium. It will also give the same working prompts to let you know how long it will take when performing tasks.

Step 22

VM console

You have some limited use of the actual VMs thanks to the console view, although it’s not as good as using the RDP method from earlier in the tutorial. Simply launch the VM from the web browser and click Console. You can also launch from the web browser and connect via VRDP.

Step 23

Advanced use

Pretty much anything you can do in the standard graphical interface is available in the web interface – including attaching and detaching drives, and importing virtual machines from other places. Of course, you don’t have to abandon the command line if there are specific operations you want to do from there.

Step 24

Headless VMs

You now have a fully operational, and fully featured, headless virtualisation server. There’s plenty more you can do with this setup, which you will be able to discover over time, but for now you should notice no difference from using it locally.