Install Oracle VirtualBox And Manage It Using phpVirtualBox On CentOS 7 Headless Server

by SK

Please share234523311

We, all, knew how to install Oracle VirtualBox on CentOS 6.x and CentOS 7.x GUI based systems. But, what about on CentOS minimal server which is not having any GUI desktop environment? No worries, VirtualBox has a tool called “VBoxHeadless”. The VBoxHeadless can help you to create and manage Virtual machines without the need of VirtualBox GUI.

In this tutorial, let us see how to install and configure Oracle VirtualBox on CentOS 6.x and CentOS 7.x minimal servers.

Install Oracle VirtualBox Extension pack

Starting with VirtualBox 4.0, we should install Extension pack that will help us to manage and connect our remote guest consoles via web interface. This 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

VirtualBox extension pack should be same version as VirtualBox base package. Download Extension pack for VirtualBox 4.3 from here.

That’s it Oracle VirtualBox and Extension pack have been installed successfully on our CentOS 6.5 server. Start using Oracle VirtualBox on your CentOS headless server. For creating and managing virtual machines from the command line, refer the official manual.

Instead, you can use Oracle VirtualBox GUI client called “phpvirtualbox”. to easily create and manage virtual machines via web browser of any remote desktop system.

Creating and managing might be bit difficult and time consuming method for some lazy administrators. If you are one of them, there is another way to create and manage VMs in the headless from a Remote system web browser using a tool called “phpvirtualbox”.

You can use Oracle VirtualBox GUI client called “phpvirtualbox” to easily create and manage virtual machines via a web browser from any remote desktop system.

What is phpVirtualBox?

phpVirtualBox is an open source, web-based client written using PHP. It can be used to manage and administer Oracle VirtualBox headless instances.

Install phpVirtualBox

Before installing phpVirtualBox, we have to install Apache web server and PHP. To install Apache, PHP refer the following links.

Configure phpVirtualBox

Change the username/password for system user that runs VirtualBox. In our case, the username/password is sk_vuser/centos.

[...]
var $username = 'sk_vuser';
var $password = 'centos';
[...]

Save and close the file.

Create a file called /etc/default/virtualbox:

vi /etc/default/virtualbox

Append the following line:

VBOXWEB_USER=sk_vuser

Now, start vboxweb-service, and make it to start automatically on every reboot.

/etc/init.d/vboxweb-service start

chkconfig vboxweb-service on

I don’t want to messing around with iptables and SElinux. So, I simply disabled them both.

In CentOS 7.x:

systemctl disable firewalld

systemctl stop firewalld

In CentOS 6.x:

service iptables stop

chkconfig iptables off

Disable SELinux:

vi /etc/sysconfig/selinux

Set SELINUX=disabled.

[...]
SELINUX=disabled
[...]

Reboot your system once to take effect all the changes.

Access phpVirtualBox Web console

Now, go to any client systems that has installed with GUI desktop environments, and try to access the URL http://ip-address-of-virtualbox-headless-server/phpvirtualbox from the web browser.

Now, try again the same URL mentioned above. The following screen should appear. Enter the username/password.

The default username/password is admin/admin.

Now, you’ll be redirected to the phpVirtualBox main dashboard.

From here, you can create, modify, delete, and manage virtual machines.

Creating sample Virtual Machine

Let us create a sample virtual machine to install Ubuntu 14.04.

Click on the New button on the top left corner. Enter the Virtual machine name.

Set the Memory size for the virtual machine.

Select “Create a virtual hard drive now” option.

Select hard drive file type.

Choose whether the new virtual hard drive file should grow as it is used (dynamically allocated) or if it should be created at its maximum size (fixed size).

Enter the size of the virtual hdd.

That’s it. The virtual machine has been created. Start installing the OS, and use the virtual machine.

phpVirtualBox tool will definitely help the system administrators who have only headless CentOS server, and also the installation is not that difficult. So, You can easily run virtual machines as many as your hardware supports from your headless CentOS server.