How to Install Oracle VirtualBox On Ubuntu 18.04 LTS Headless Server

Install Oracle VirtualBox On Ubuntu 18.04

This step by step tutorial walk you through how to install Oracle VirtualBox on Ubuntu 18.04 LTS headless server. And, this guide also describes how to manage the VirtualBox headless instances using phpVirtualBox, a web-based front-end tool for VirtualBox. The steps described below might also work on Debian, and other Ubuntu derivatives such as Linux Mint. Let us get started.


Before installing Oracle VirtualBox, we need to do the following prerequisites in our Ubuntu 18.04 LTS server.

First of all, update the Ubuntu server by running the following commands one by one.

$ sudo apt update
$ sudo apt upgrade
$ sudo apt dist-upgrade

Next, install the following necessary packages:

$ sudo apt install build-essential dkms unzip wget

After installing all updates and necessary prerequisites, restart the Ubuntu server.

$ sudo reboot

Install Oracle VirtualBox on Ubuntu 18.04 LTS server

Add Oracle VirtualBox official repository. To do so, edit /etc/apt/sources.list file:

$ sudo nano /etc/apt/sources.list

Add the following lines.

Here, I will be using Ubuntu 18.04 LTS, so I have added the following repository.

deb bionic contrib

Replace the word ‘bionic’ with your Ubuntu distribution’s code name, such as ‘xenial’, ‘vivid’, ‘utopic’, ‘trusty’, ‘raring’, ‘quantal’, ‘precise’, ‘lucid’, ‘jessie’, ‘wheezy’, or ‘squeeze‘.

Then, run the following command to add the Oracle public key:

$ wget -q -O- | sudo apt-key add -

For VirtualBox older versions, add the following key:

$ wget -q -O- | sudo apt-key add -

Next, update the software sources using command:

$ sudo apt update

Finally, install latest Oracle VirtualBox latest version using command:

$ sudo apt install virtualbox-5.2

Adding users to VirtualBox group

We need to create and add our system user to the vboxusers group. You can either create a separate user and assign it to vboxusers group or use the existing user. I don’t want to create a new user, so I added my existing user to this group. Please note that if you use a separate user for virtualbox, you must log out and log in to that particular user and do the rest of the steps.

I am going to use my username named sk, so, I ran the following command to add it to the vboxusers group.

$ sudo usermod -aG vboxusers sk

Now, run the following command to check if virtualbox kernel modules are loaded or not.

$ sudo systemctl status vboxdrv

As you can see in the above screenshot, the vboxdrv module is loaded and running!

For older Ubuntu versions, run:

$ sudo /etc/init.d/vboxdrv status

If the virtualbox module doesn’t start, run the following command to start it.

$ sudo /etc/init.d/vboxdrv setup

Great! We have successfully installed VirtualBox and started virtualbox module. Now, let us go ahead and  install Oracle VirtualBox extension pack.

Install VirtualBox Extension pack

The VirtualBox Extension pack provides the following functionalities to the VirtualBox guests.

  • The virtual USB 2.0 (EHCI) device
  • VirtualBox Remote Desktop Protocol (VRDP) support
  • Host webcam passthrough
  • Intel PXE boot ROM
  • Experimental support for PCI passthrough on Linux hosts

Download the latest Extension pack for VirtualBox 5.2.x from here.

$ wget

Install Extension pack using command:

$ sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.14.vbox-extpack

Congratulations! We have successfully installed Oracle VirtualBox with extension pack in Ubuntu 16.04 LTS server. It is time to deploy virtual machines. Refer the virtualbox official guide to start creating and managing virtual machines in command line.

Not everyone is command line expert. Some of you might want to create and use virtual machines graphically. No worries! Here is where phpVirtualBox comes in handy!!

About phpVirtualBox

phpVirtualBox is a free, web-based front-end to Oracle VirtualBox. It is written using PHP language. Using phpVirtualBox, we can easily create, delete, manage and administer virtual machines via a web browser from any remote system on the network.

Install phpVirtualBox in Ubuntu 18.04 LTS

Since it is a web-based tool, we need to install Apache web server, PHP and some php modules.

To do so, run:

$ sudo apt install apache2 php php-mysql libapache2-mod-php php-soap php-xml

Then, Download the phpVirtualBox 5.2.x version from the releases page. Please note that we have installed VirtualBox 5.2, so we must install phpVirtualBox version 5.2 as well.

To download it, run:

$ wget

Extract the downloaded archive with command:

$ unzip

This command will extract the contents of file into a folder named “phpvirtualbox-5.2-0”. Now, copy or move the contents of this folder to your apache web server root folder.

$ sudo mv phpvirtualbox-5.2-0/ /var/www/html/phpvirtualbox

Assign the proper permissions to the phpvirtualbox folder.

$ sudo chmod 777 /var/www/html/phpvirtualbox/

Next, let us configure phpVirtualBox.

Copy the sample config file as shown below.

$ sudo cp /var/www/html/phpvirtualbox/config.php-example /var/www/html/phpvirtualbox/config.php

Edit phpVirtualBox config.php file:

$ sudo nano /var/www/html/phpvirtualbox/config.php

Find the following lines and replace the username and password with your system user (The same username that we used in “Adding users to VirtualBox group” section).

In my case, my Ubuntu system username is sk, and its password is ubuntu.

var $username = 'sk';
var $password = 'ubuntu';

Save and close the file.

Next, create a new file called /etc/default/virtualbox:

$ sudo nano /etc/default/virtualbox

Add the following line. Replace ‘sk’ with your own username.


Finally, Reboot your system or simply restart the following services to complete the configuration.

$ sudo systemctl restart vboxweb-service
$ sudo systemctl restart vboxdrv
$ sudo systemctl restart apache2

Adjust firewall to allow Apache web server

By default, the apache web browser can’t be accessed from remote systems if you have enabled the UFW firewall in Ubuntu 18.04 LTS. You must allow the http and https traffic via UFW by following the below steps.

First, let us view which applications have installed a profile using command:

$ sudo ufw app list
Available applications:
Apache Full
Apache Secure

As you can see, Apache and OpenSSH applications have installed UFW profiles.

If you look into the “Apache Full” profile, you will see that it enables traffic to the ports 80 and 443:

$ sudo ufw app info "Apache Full"
Profile: Apache Full
Title: Web Server (HTTP,HTTPS)
Description: Apache v2 is the next generation of the omnipresent Apache web


Now, run the following command to allow incoming HTTP and HTTPS traffic for this profile:

$ sudo ufw allow in "Apache Full"
Rules updated
Rules updated (v6)

If you want to allow https traffic, but only http (80) traffic, run:

$ sudo ufw app info "Apache"

Access phpVirtualBox Web console

Now, go to any remote system that has graphical web browser.

In the address bar, type: http://IP-address-of-virtualbox-headless-server/phpvirtualbox.

In my case, I navigated to this link –

You should see the following screen. Enter the phpVirtualBox administrative user credentials.

The default username and phpVirtualBox is admin/admin.

Congratulations! You will now be greeted with phpVirtualBox dashboard.

Now, start creating your VMs and manage them from phpvirtualbox dashboard. As I mentioned earlier, You can access the phpVirtualBox from any system in the same network. All you need is a web browser and the username and password of phpVirtualBox.

If you haven’t enabled virtualization support in the BISO of host system (not the guest), phpVirtualBox allows you to create 32-bit guests only. To install 64-bit guest systems, you must enable virtualization in your host system’s BIOS. Look for an option that is something like “virtualization” or “hypervisor” in your bios and make sure it is enabled.

That’s it. Hope this helps. If you find this guide useful, please share it on your social networks and support us.

More good stuffs to come. Stay tuned!

Reference links:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...

10 Responses

  1. Gianni Franceschinis says:

    This is a great guide.
    Thanks so much!!!

  2. Daryl Lee says:

    Nice work. But when I browse to phpvirtualbox and log in, I get a failure to connect to “”. Any idea what that’s all about? The userid/pwd is correct

  3. Chuck Razalas says:

    Great tutorial but like every other time I have tried I get the same issue about failure to connect to “” and I have changed the IP and I have changed the usernames and I have made sure to allow the port 18083 and no matter what I do it NEVER works. I have tried on CentOS 7 and now Ubuntu 16.04 LTS and same issue every single time no matter what tutorial I try. I followed this guide to a “T” and same as all the rest. Why is this so complicated and why does it NEVER work?

    • Chuck Razalas says:

      Ok never mind. I finally got it to work. I didn’t change the this time and most importantly, I made sure I did all the steps with the correct User this time. So overall your tutorial was 100% dead on I just didn’t follow the users clause so that was on me. Thanks so much for providing a tutorial that was easy to follow and that actually worked for me.

  4. Chuck Razalas says:

    Quick question SK. Ok so I have everything working perfectly and I did end up having to change the IP to my actual server IP after all. I can login to the PHP Virtual box login and I can see the VM I created and it’s running and all is well except one problem. I can only see it in the console screen and I cannot access the VM from a web browser. My VM is Univention Corporate Server and again I can see it running in the Console but I need to access the Univention Portal from a web browser and not the Virtual Box console. How can I see a VM I create from the outside? No matter what I do I just can’t access it. Thanks in advance.

    • SK says:

      If both systems (VM and the host) are in the same network, you can access it from the web browser. Check the network settings of your VM and make sure you have selected the “Bridged network” option.

      • Chuck Razalas says:

        One problem with that SK. My hosting company 1&1 doesn’t allow Bridging, go figure right? So what I have tried is using adapter 1 as Host Only and adapter 2 as Nat but no luck. I even tried port forwarding from my server ip to and still no luck. Also tried adding the following command in IP Tables: iptables -t nat -A PREROUTING -p tcp -d my.server.ip –dport 80 -j DNAT –to-destination and also no luck. I have tried with Ubuntu 16.04 LTS and now trying again with CentOS 7 as the base. The VirtualBox install process goes off without a hitch. I am then trying to install Univention Corporate Server as a VM in VirtualBox and it installs but always says it could not set a default route and makes me manually enter my netwwork details. I input my server ip, then the submask comes up and it’s different than what the host server submask actually is. I change it to what it is on the actual host server, then when Gateway comes up I try what my hosting company says the host Gateway IP is and always get an error saying it’s unreachable. I then try again with the auto defaults that pop up and again nothing. I’m so frustrated with this at this point. Any other ideas?

        • SK says:

          Hello Chuck, enabling bridge network on VM has nothing to do with hosting provider as far as I know. Because, you’re enabling it on your VM, not in the host system. The VM (The univention server) should be reachable in-order to access it from a remote system. I am not a expert in networking. I don’t know how to do it. My apologies.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.