Install VirtualBox 6.1 on Ubuntu 18.04 or 20.04 via Official repository + web GUI
Sometimes official documentation is hard to follow, especially if you want to test something only or just get started. I made a write-up particularly for Ubuntu 18.04 including 18.04.1–18.04.4 iterations.
Updated 2021–03–04: For Ubuntu 20.04, need to change from bionic to focal, and version of extension. Also added steps to install web interface.
Preparation
Before getting started make sure you don’t have an old one. If you installed from ubuntu repository, it’s could be around VirtualBox 5.2 :)
sudo apt remove --purge -y virtualbox
sudo apt autoremove -y
add the official repository
sudo bash -c "echo deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian bionic contrib > /etc/apt/sources.list.d/virtualbox.list"
for ubuntu 20.04
sudo bash -c "echo deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian focal contrib > /etc/apt/sources.list.d/virtualbox.list"
add GPG Keys
For official repository need to add GPG keys
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
Installation
sudo apt update && sudo apt install -y virtualbox-6.1
Verify the installation and version
vboxmanage --version
6.1.6r137129
Download and install an extension
Need to download install an extension package I am doing it from terminal. Just to make sure that installed version matching the extension version/
# Downloadwget https://download.virtualbox.org/virtualbox/6.1.6/Oracle_VM_VirtualBox_Extension_Pack-6.1.6.vbox-extpack# installsudo vboxmanage extpack install --replace Oracle_VM_VirtualBox_Extension_Pack-6.1.6.vbox-extpack
For 6.1.8 version
# Downloadwget https://download.virtualbox.org/virtualbox/6.1.18/Oracle_VM_VirtualBox_Extension_Pack-6.1.18.vbox-extpack # installsudo vboxmanage extpack install --replace Oracle_VM_VirtualBox_Extension_Pack-6.1.18.vbox-extpack
open with Virtualbox and install. It will ask for admin password.
additionally steps for Web interface
Additionally a few steps to install web interface:
first install Apache2 server, is mysql isn’t needed.
sudo apt install -y apache2 libapache2-mod-php php php-soap php-xml
and download.
wget 'http://sourceforge.net/projects/phpvirtualbox/files/latest/download' -O ~/phpvirtualbox.zip
Extract archive to your directory
unzip ~/phpvirtualbox.zip
one more thing
sudo mv phpvirtualbox-5.0-5/ /var/www/html/virtualboxcd /var/www/html/virtualbox/
edit config file
cp config.php-example config.php
nano config.php
add username and password assuming you have user vbox with password pass
var $username = 'vbox';
var $password = 'pass';
also need to add this user to vbox group.
sudo usermod -aG vboxusers vbox
create a new file with name
sudo nano /etc/default/virtualbox
and add settings
VBOXWEB_USER=vbox
And finally restart services below:
sudo systemctl restart vboxweb-servicesudo systemctl restart vboxdrvsudo systemctl restart apache2
Please note, to upgrade virtualbox you need to stop all your vms and vboxdrv service before upgrading.
Default login creadentials are admin/admin it also on port 80 without SSL, just keep in mind.
Reference:
# 1 https://www.virtualbox.org/wiki/Linux_Downloads
# 2 https://ostechnix.com/install-oracle-virtualbox-ubuntu-16-04-headless-server/