Setup Virtual Machines using VirtualBox on a Dedibox

VirtualBox Overview

Oracle VM VirtualBox is a free and open-source hypervisor for x86 virtualization. It is being developed by Oracle Corporation and the base package is released under the GNU General Public License V2.

It is an alternative to other hypervisors like Proxmox or VMware ESXi.

The following steps are neccessary to install the VirtualBox hypervisor and phpVirtualBox, a web based configuration interface on a server:


Installing the VirtualBox Hypervisor

Note: This tutorial assumes that you have already completed the installation of Ubuntu 18.04 on your Scaleway Dedibox from the console.

1 . Log into your server using SSH.

~# ssh user@<server_ip>

2 . In case you are connected as a regular user, switch into the root account using sudo:

~# sudo su

3 . Update the apt package cache and upgrade the software already installed on the machine to the latest version available in the repositories:

~# apt update && apt upgrade -y 

4 . Install the following prerequisites using apt:

~# apt install build-essential dkms unzip wget -y

5 . Download and install the VirtualBox public key:

~# wget -q -O- | apt-key add -

6 . Create a configuration file for the VirtualBox repository:

~# sh -c "echo 'deb bionic contrib' > /etc/apt/sources.list.d/virtualbox.list"

7 . Update apt:

~# apt update

8 . Install VirtualBox Version 6.1 using the apt package manager:

~# apt install virtualbox-5.2

9 . Check if the virtualbox service is running:

~# systemctl status vboxdrv

The output should look like the following example:

● vboxdrv.service - VirtualBox Linux kernel module
   Loaded: loaded (/usr/lib/virtualbox/; enabled; vendor preset: enabl
   Active: active (exited) since Thu 2020-04-16 17:28:25 CEST; 10s ago
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/vboxdrv.service

Creating a VirtualBox User

1 . Create a new user for VirtualBox. It is named vbox in the following example, but you can use a name of your choice:

~# adduser vbox

2 . Add the user to the group vboxusers

~# usermod -aG vboxusers vbox

Installing the VirtualBox Extension Pack

The VirtualBox expansion pack provides support for USB 2.0 and USB 3.0 devices, VirtualBox RDP, disk encryption, NVMe and PXE boot for Intel cards.

Note: The Extension Pack binaries are released under the VirtualBox Personal Use and Evaluation License (PUEL).

1 . Download the expansion pack using wget:

~# wget

2 . Install the expansion pack by running the following command:

~# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.40.vbox-extpack

Installing phpVirtualBox

phpVirtualBox is an open source web application written in PHP, allowing you to manage virtual machines from an easy to use web interface.

1 . Install the Apache web server and PHP using apt:

~# apt install apache2 php php-mysql libapache2-mod-php php-soap php-xml -y

2 . Download the application from its GitHub repository:

~# wget

3 . Unzip the downloaded file:

~# unzip

4 . Move the downloaded folder to its final destination /var/www/html/phpvirtualbox:

~# mv phpvirtualbox-5.2-1/ /var/www/html/phpvirtualbox

5 . The application provides a example configuration file, copy its content into an actual configuration file that will be used:

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

6 . Open the configuration file in a text editor, for example nano:

~# nano /var/www/html/phpvirtualbox/config.php

7 . Go to the following lines and replace the values with the system user (for example vbox) and its assoicated password, configured in a previous step. Set the value for $vrdeaddress and $consoleHost to the public IP of your dedicated server to be able to connect to the remote console of your virutal machines:

/* Username / Password for system user that runs VirtualBox */
var $username = 'vbox';
var $password = '<a_secret_password>';

/* Set the default VRDE address, e.g. */
var $vrdeaddress = '<your_servers_ip>';
var $consoleHost = '<your_servers_ip>';

Then save the file and exit the text editor.

8 . Open the VirtualBox init script in a text editor, for example nano

~# nano /etc/default/virtualbox

9 . Add a new line at the end of the file, remember to replace vbox with the name of your user, if different:


10 . Restart the vboxweb-service:

~# systemctl restart vboxweb-service

11 . Restart vboxdrv:

~# systemctl restart vboxdrv

Securing the Hypervisor

Adding TLS Encryption to the Apache Web Server

To secure the connection between the the web browser and the Apache web server HTTPS should be configured. A TLS certificate can be obtained and managed for free from the Let’s Encrypt certificate authority by using the certbot application.

1 . Install the pre-required packages and repositories:

~# apt install software-properties-common -y && add-apt-repository universe -y && add-apt-repository ppa:certbot/certbot -y

2 . Update the apt package cache:

~# apt update

3 . Install Certbot via apt:

~# apt install certbot python-certbot-apache -y

4 . Create a configuration file for phpVirtualBox, by making a copy of the default configuration:

~# cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/

5 . Open the file in a text editor:

~# nano /etc/apache2/sites-available/

Edit the following lines to match your configuration, add them to the file, save it and exit the editor:

DocumentRoot /var/www/html/phpvirtualbox/

7 . Activate the new site:

~# a2ensite

8 . Reload the Apache configuration to enable the new site:

~# systemctl reload apache2

4 . Run Certbot to request a certificate:

~# certbot --apache

Certbot will ask you a couple of questions:

  • In a first step Certbot asks for your email address. Enter it and press Enter on your keyboard.
  • You will then be asked to agree to the terms of service, confirm it by pressing on A.
  • Decide if you want to share your email address with the Electronic Frontier Foundation (EFF). Press Y for yes or N for no.
  • Following you will be asked for which domains you want to activate SSL. Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown.
  • Certbot asks if all traffic should be forced to HTTPS. Type 1 for no or 2 for yes.

The certificate is being requested and the following message appears once it has been obtained:

Congratulations! You have successfully enabled

You should test your configuration at:

Configuring a Firewall

A firewall controls incoming and outgoing network traffic based on predefined security rules. To protect your server from potential attacks or security issues, install UFW (or Uncomplicated FireWall), a frontend for IPTables to simplify the configuration.

1 . Install ufw using the apt package manager:

~# apt install ufw 

2 . Configure a rule that denies everything by default:

~# ufw default deny

3 . Enable outgoing traffic

~# ufw default allow outgoing

4 . Authorize SSH connections:

~# ufw allow 22/tcp

5 . Authorize HTTPS connections:

~# ufw allow 443/tcp

6 . Allow connections to the RDP port-range used for the serial console of the VM’s running on the hypervisor:

~# ufw allow 9000:9100/tcp

7 . Apply the firewall rules:

~# ufw enable

8 . Confirm the application of the firewall rules by pressing Y when prompted:

Command may disrupt existing ssh connections. Proceed with operation (y|n)?

Creating Virtual Machines using phpVirtualBox

To create virtual machines using phpVirtualBox, open a web browser on your local computer and go to - replace with the IP address or the domain name of your server.

1 . The phpVirtualBox login prompt displays. Enter the credentials admin / admin and click on Log in:

Important: Change the admin password immediately after the first login for security reasons. To change the password click on File > Change password once logged in.

2 . The phpVirtualBox dashboard displays:

3 . Click New to launch the virtual machine creation wizard.

4 . Enter a name and operating system information:

Note: This example describes the creation of an Ubuntu 18.04 virtual machine. If you want to install another operating system modify the parameters accordingly.

  • Name: a friendly name for the virtual machine (For example: Ubuntu VM)
  • Type: Linux
  • Version: Ubuntu (64-bit)

5 . Select the amount of memory (RAM) in megabytes to be allocated to the virtual machine, then click Next

6 . Select the option Create a virtual hard disk now and click Create.

7 . Choose the type of the hard disk file. If you do not need to use it with other virtualization software, leave the default setting and click next:

8 . Choose whether the new virtual hard disk file should grow as it is used (dynamically allocated) or if it should be created at its maximum size (fixed size), then click Next:

9 . Choose the location for the hard disk file and its size. By default it will be created inside the virtual machines folder. Click Create to create the new VM.

10 . Click on the network tab from the VirtualBox dashboard:

11 . Configure the network adapter’s attachment to Bridged Mode and set the MAC address of the interface to the virtual MAC address linked to your failover IP.

12 . Click on Storage in the VirtualBox webinterface. Select the ISO file for the installation as virtual CD-ROM drive. You can download the ISO of your preferred OS on your server using the wget command.

13 . Boot the virtual machine by clicking on Start and follow the installation process of your OS either from the built-in console, or using a RDP client.

14 . Once the installation has completed, log into your operating system and configure the [networking] of the virtual machine. Use the ip link show command to dertermine the name of the virtual network interface.

15 . The basic installation of your VM is now complete, you can continue to install your applications.

16 . Disable the RDP server for the virtual machine for security reasons, by clicking on Display in the dashboard, then uncheck Enable Server and click OK to confirm:


You have configured now a Scleway Dedibox server running the VirtualBox hypervisor, installed the phpVirtual Box administration web interface, secured the connection to it using an encrypted connection and restricted access to the machine by configuring a firewall. Then you have deployed your first Virtual Machine using the phpVirtualBox administration panel. You can continue to setup more virtual machines on your hypervisor to deploy the infrastructure needed for your projects. For more information, you may refer to the official VirtualBox documentation.

Discover a New Cloud Experience

Deploy SSD Cloud Servers in seconds.