Phpvirtualbox for Ubuntu 16.04 Server – Install Tutorial 2016

Install VirtualBox

Login as Root and install virtualbox

sudo su

apt install virtualbox

Lamp Server

We need to install apache and php7, you can remove mysql-server from the list if you don’t want to add it right now.

apt install apache2

apt install mysql-server php7.0 libapache2-mod-php7.0 php-xml php-soap

Make a new directory and modify apache DocumentRoot

user = your login name

mkdir /home/user/public_html

chmod 777 /home/user/public_html

nano /etc/apache2/sites-available/000-default.conf

change DocumentRoot to this:

DocumentRoot /home/user/public_html

and add this, just like in image:

<Directory "/home/user/public_html">
Require all granted
</Directory>

screenshot_9

Add json and soap extensions to php config file

nano /etc/php/7.0/apache2/php.ini

scroll down till you see extension list and add these, and then just restart apache:

extension=json.so

extension=soap.so
/etc/init.d/apache2 restart

PhpVirtualBox

Now we need to download phpvirtualbox

wget http://downloads.sourceforge.net/project/phpvirtualbox/phpvirtualbox-5.0-5.zip

And get it out of zip file, so install unzip

apt install unzip

unzip phpvirtualbox-5.0-5.zip

If the link is not working you can get it from here: https://sourceforge.net/projects/phpvirtualbox/ 
You need to click Download and copy Direct link

Modify phpvirtualbox example config file

Change if you need: vbox = username for your virtualbox config

cd phpvirtualbox-5.0-5

nano config.php-example

var $username = 'vbox';
var $password = 'mypassword';

var $location = 'http://localhost:18083/';

scroll to the bottom of file and add this: ?> if it doesn’t exist already

then save it as ”config.php

Move phpvirtualbox dir to your apache directory

cd ../
mv phpvirtualbox-5.0-5 public_html/phpvirtualbox
cd public_html

chmod 755 phpvirtualbox

chown vbox:vboxusers phpvirtualbox

Make a new user and usergroup

useradd -m vbox -G vboxusers

Edit virtualbox config file

nano /etc/default/virtualbox

This goes at the end of file:

VBOXWEB_USER=vbox

VBOXWEB_HOST=localhost

If you can’t login through phpvirtualbox webapp, then you can try to add this:

VBOXWEB_AUTH_LIBRARY=null

It should point out you in the right way finding out the problem.

One more thing, we need to add vboxwebsrv app in the boot process. Edit custom boot list:

nano /etc/rc.local

Write this: sudo -u vbox vboxwebsrv. Make sure that the file ends with: exit 0

Then reboot your system if you don’t want to start it with screen command

And its working! Or not?

Screenshot_1

16.10 Users

Login on phpvirtualbox website with admin:admin -> File -> Change password.

Replace:

VBOXWEB_USER=vbox with VBOXWEB_USER=root

And

Type your system login names in config.php file:

var $username = 'user';
var $password = 'password';

Or create another account with different name, set password with passwd user. “Vbox” is not allowed in config.php file.

Type top in shell to see if “vboxwebsrv” is running. If not, you need to play with “/etc/default/virtualbox” file or just start it manually. There’s a service script which should start it at boot but it never works, especially if you have Samba on your system.

Config.php user settings and with what account vboxwebsrv is launched needs to be same.

How to fix vboxweb service file and add it in boot process (tested in 16.10):

vboxweb service file location: /lib/systemd/system/vboxweb.service

Edit permissions:

chmod 755 /lib/systemd/system/vboxweb.service

and check if it’s just not empty file:

nano /lib/systemd/system/vboxweb.service

Incase it’s empty, add this:

[Unit]
Description=VirtualBox Web Service
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/vboxwebsrv --pidfile /run/vboxweb.pid --background
PIDFile=/run/vboxweb.pid

[Install]
WantedBy=multi-user.target

Now Enable it:

systemctl enable vboxweb.service

now reboot and see if you can login on phpvirtualbox website without starting vboxwebsrv manually

If it didn’t work you might wan’t to edit:

nano /etc/systemd/system/multi-user.target.wants/vboxweb.service

or use Webmin:

screenshot_9

And add User and usergroup right here:

[Service]
Type=forking
ExecStart=/usr/bin/vboxwebsrv --pidfile /run/vboxweb.pid --background
PIDFile=/run/vboxweb.pid
User=(username you use in /etc/default/virtualbox file, make sure it got password)
Group=(usergroup ^)

Some people say it might ruin virtual disk file with root user, when you resize it. So check it out before you do anything important.

Advertisements

14 thoughts on “Phpvirtualbox for Ubuntu 16.04 Server – Install Tutorial 2016

      1. Included already in that file, but now is saying is missing this The character device /dev/vboxdrv does not exist.

        Like

  1. vboxwebsrv was not installed, don’t know how it happened. However after installing it, I’m getting vboxwebsrv: error: Failed to initialize COM because the global settings directory ‘/home/ledilek/.config/VirtualBox’ is not accessible!

    Like

  2. The character device /dev/vboxdrv does not exist.Please install the virtualbox-dkms package and the appropriate headers, most likely linux-headers-generic. What could be the problem here. Thanks in advance

    Like

  3. I’m getting the same error as Ledile:

    Feb 28 18:29:07 reaper vboxweb-service.sh[1683]: Starting VirtualBox web serviceSignature not found in user keyring
    Feb 28 18:29:07 reaper vboxweb-service.sh[1683]: Perhaps try the interactive ‘ecryptfs-mount-private’
    Feb 28 18:29:08 reaper vboxweb-service.sh[1683]: VBoxManage: error: Failed to initialize COM because the global settings director
    Feb 28 18:29:08 reaper vboxweb-service.sh[1683]: …fail!
    Feb 28 18:29:08 reaper vboxweb-service.sh[1683]: …done.

    Any Idea how to resolve this issue when booting. It works if I start manually after boot.

    Like

    1. Just like on stackoverflow.com I find a solution, after two day of trying, as soon I post a question. But, the solution was to add VBOXWEB_USER=vbox with VBOXWEB_USER=root. I read that but hadn’t tried because I’m using 16.04.

      Also, great job on the tutorial is was very helpful!!

      Like

  4. I need help, when I access http://“IP”/phpvirtualbox and insert my Username and Password, the follow situation occured

    Could not connect to host (http://127.0.0.1:18083/)
    Exception Object
    (
    [message:protected] => Could not connect to host (http://127.0.0.1:18083/)
    [string:Exception:private] =>
    [code:protected] => 64
    [file:protected] => /home/teleadmin/public_html/phpvirtualbox/endpoints/api.php
    [line:protected] => 134
    [trace:Exception:private] => Array
    (
    )

    [previous:Exception:private] =>
    )

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s