Learn how to manage headless VirtualBox with phpVirtualBox on Ubuntu Linux

|

|

The post walks readers through the process of managing VirtualBox 5.2 on a headless Ubuntu 16.04 LTS server using phpVirtualBox. It outlines the prerequisites, including the installation of VirtualBox and PHP 7.1 with related modules. The instructions then proceed to cover the installation of Apache2 HTTP server, PHP 7.1, and finally, phpVirtualBox. Guidance is also…

This article explains using phpVirtualBox to manage headless VirtualBox guest machines on Ubuntu Linux

phpVirtualBox is a web-based graphical user interface that allows you to manage headless VirtualBox guest machines on Ubuntu Linux. It can help you easily create and manage multiple virtual guest machines, which can be very useful if you are dealing with many machines.

It provides a user-friendly interface that can be accessed from any modern web browser, which makes it easy to use from anywhere. Additionally, it allows you to perform most of the operations you can do with the VirtualBox GUI directly from a web browser, making it a powerful tool for managing headless servers.

Again, Virtualization software like VirtualBox and VMware Workstation Pro or VMware Players allow users to run multiple guest operating systems simultaneously on a single host computer.

To get started with managing VirtualBox headless servers via phpVirtualBox, continue below:

Prerequisites – Install VirtualBox

Before you can install phpVirtualBox, you must first install VirtualBox. The link below shows you how to do just that.

Now that VirtualBox is installed, your next step is to install phpVirtualBox.

Install Apache2 HTTP Server

After installing VirtualBox, as described in our previous post, run the commands below to install the Apache2 HTTP server.

sudo apt install apache2

Install PHP 7.1 and Related Modules

PHP 7.1 isn’t available on Ubuntu default repositories… to install it, you will have to get it from third-party repositories.

Run the commands below to add the below third party repository to upgrade to PHP 7.1

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Then update and upgrade to PHP 7.1

sudo apt update

Run the commands below to install PHP 7.1 and related modules.

sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common libapache2-mod-php7.1 php7.1-mbstring php7.1-soap php7.1-xml php7.1-mysql php7.1-cli

After installing PHP 7.1 modules, run the commands below to open the Apache2 PHP default configuration file.

sudo nano /etc/php/7.1/apache2/php.ini

Then add the lines below just before Dynamic Extensions

extension=json.so
extension=soap.so

Save the file and exit.

Reload Apache2 HTTP Server

sudo systemctl reload apache2.service

Install phpVirtualBox

Finally, run the commands below to download the phpVirtualBox package

cd /tmp && wget https://sourceforge.net/projects/phpvirtualbox/files/phpvirtualbox-5.0-5.zip

After downloading, run the commands below to unzip the package and copy it to the Apache2 default document root directory.

unzip phpvirtualbox-5.0-5.zip
sudo mv phpvirtualbox-5.0-5 /var/www/html/phpvirtualbox

Next, run the commands below to create a phpVirtualBox configuration file from its sample file.

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

Create a phpVirtualBox dedicated user account

phpVirtualBox requires a dedicated user account to manage the VirtualBox. For that, you need to create a service account.

To create a service account called vbox and add the user to the vboxusers group. Run the commands below and the second line to create a new password.

sudo useradd -m vbox -G vboxusers
sudo passwd vbox

Next, set the permissions for the phpVirtualBox directory for the vbox user.

sudo chown -R vbox:vboxusers /var/www/html/phpvirtualbox
sudo chmod -R 755 /var/www/html/phpvirtualbox

Setup phpVirtualBox connection

The final step is to configure the phpVirtualBox user connection. This can be done by opening its default configuration file and adding the phpvbox user to the settings.

Open and edit the file by running the commands below:

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

Then, fill in the user account for phpvbox, as shown below.

/* Username / Password for system user that runs VirtualBox */
var $username = ‘vbox‘;
var $password = ‘vbox_password‘;
var $location = ‘http://localhost:18083/’;

Next, run the commands below to open the VirtualBox config file in the /etc/default directory.

sudo nano /etc/default/virtualbox

Then, add these lines at the end of the file and save it. This allows VirtualBox SOAP API service to run as vbox.

VBOXWEB_USER=vbox
VBOXWEB_HOST=localhost

Finally, start the phpVirtualBox service account by running the commands below.

sudo systemctl enable vboxwebsrv.service
sudo systemctl start vboxwebsrv.service
sudo systemctl reload apache2.service

Restart the Apache2 server, then browse to the host via IP or hostname followed by /phpvirtualbox

http://example/phpvirtualbox

This is how to manage VirtualBox remotely.

Enjoy!

You may also like the post below:

Like this:



13 responses to “Learn how to manage headless VirtualBox with phpVirtualBox on Ubuntu Linux”

  1. Justin Avatar
    Justin

    Thanks for the tutorial. Once I try to start the vboxwebsrv.service I am greeted with: Failed to execute operation: No such file or directory

    Any thoughts?

    1. Mark Avatar
      Mark

      I’m having the same issue as Justin when trying to start vboxwebsrv.service

    2. Ed Avatar
      Ed

      I found it has been renamed to vboxweb-service.service in virtualbox 5.2

  2. Event Avatar
    Event

    Hi, I have no vboxwebsrv.service, but vboxweb-service.service file. I have the same issue as Justin and Mark.
    I’m tryin’ to resolve it.

  3. Dave Avatar
    Dave

    any resolution? I am getting the same.

    1. Dean Avatar
      Dean

      Perhaps it’s this?
      sudo systemctl start vboxweb-service.service

  4. Tim Avatar
    Tim

    After fixing the problem with “systemctl start vboxweb-service.service” i wasnt able to login to the phpvirtualbox panel.. try to use the new version of phpvitualbox, not the one from sourceforge and it will work! 😉

  5. Don Avatar
    Don

    Many thanks for the clear and concise how-to, but the inability to login is definitely frustrating. @Tim, your “try to use the new version of phpvirtualbox” may help, but from where do you get it besides from SourceForge?

    I gather a problem is the change from vboxwebsrv.service to vboxweb-service.service when using systemctl in Ubuntu. I’ve precisely followed the steps here but end up with “An unknown PHP error” dialog at login and can not find any syntax errors in the config file.

    My VirtualBox is 5.2.12r122591 with 5.2.12 Extension Pack. PHP 7.0, 7.1, 7.2 installed. (Are multiple installed versions a problem?)

    Any suggestions appreciated.

  6. Don Avatar
    Don

    Still frustrated with failed logins. I’ve worked with a couple of pristine config.php-example files changing only my username and password to those of the server host to create a config.php.

    My services:
    vboxautostart-service.service loaded active exited
    vboxballoonctrl-service.service loaded active exited
    vboxdrv.service loaded active exited
    vboxweb-service.service loaded active running
    vgauth.service loaded inactive dead
    virtualbox.service loaded active exited

  7. Tudor Avatar
    Tudor

    Please note that phpvirtualbox is no longer on Sourceforge. It has moved to https://phpvirtualbox.github.io/

  8. jibba jabba Avatar
    jibba jabba

    Meanwhile, you need Flash to run the guest VNC seems to be a rather BIG part of actually using these headless installs so now flash is deemed dangerous and indeed hard to even find and install in a generic debian 9 openmediavault install https://www.openmediavault.org/download.html

    how do we actually make use of these VMS from for instance a generic aprilwin10 install and for the better option how do we make these headless vm’s with minimal x install talk directly to a generic curent (july 2018) https://sourceforge.net/projects/vcxsrv/ and putty ssh/X11 /enabled X11 forwarding

  9. Sudhashen Naicker Avatar
    Sudhashen Naicker

    replace phpvirtualbox with latest from github as comment above and follow same procedure and it works! thank you.

  10. Harold Roberts Avatar
    Harold Roberts

    Ho do you get the latest from github?

Leave a Reply to Don Cancel 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.