The following steps are neccessary to install the VirtualBox hypervisor and phpVirtualBox, a web based configuration interface on a server:
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 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 install build-essential dkms unzip wget -y
5 . Download and install the VirtualBox public key:
~# wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | apt-key add -
6 . Create a configuration file for the VirtualBox repository:
~# sh -c "echo 'deb http://download.virtualbox.org/virtualbox/debian bionic contrib' > /etc/apt/sources.list.d/virtualbox.list"
7 . Update
~# 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/vboxdrv.sh; 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
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
~# usermod -aG vboxusers vbox
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 https://download.virtualbox.org/virtualbox/5.2.40/Oracle_VM_VirtualBox_Extension_Pack-5.2.40.vbox-extpack
2 . Install the expansion pack by running the following command:
~# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.40.vbox-extpack
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 install apache2 php php-mysql libapache2-mod-php php-soap php-xml -y
2 . Download the application from its GitHub repository:
~# wget https://github.com/phpvirtualbox/phpvirtualbox/archive/5.2-1.zip
3 . Unzip the downloaded file:
~# unzip 5.2-1.zip
4 . Move the downloaded folder to its final destination
~# 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 /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
$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. 192.168.1.1 */ 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 /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
~# systemctl restart vboxweb-service
11 . Restart
~# systemctl restart vboxdrv
To secure the connection between 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 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/phpvirtualbox.example.com.conf
5 . Open the file in a text editor:
~# nano /etc/apache2/sites-available/phpvirtualbox.example.com.conf
Edit the following lines to match your configuration, add them to the file, save it and exit the editor:
ServerAdmin firstname.lastname@example.org ServerName phpvirtualbox.example.com DocumentRoot /var/www/html/phpvirtualbox/
7 . Activate the new site:
~# a2ensite phpvirtualbox.example.com
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:
Enteron your keyboard.
Yfor yes or
1for no or
The certificate is being requested and the following message appears once it has been obtained:
Congratulations! You have successfully enabled https://phpvirtualbox.example.com
You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=phpvirtualbox.example.com
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)?
To create virtual machines using phpVirtualBox, open a web browser on your local computer and go to
https://phpvirtualbox.example.com - replace
phpvirtualbox.example.com with the IP address or the domain name of your server.
1 . The phpVirtualBox login prompt displays. Enter the credentials
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.
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:
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
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.