Installing VirtualBox with headless support

From Fyzix
Jump to: navigation, search

Reference: deb http://download.virtualbox.org/virtualbox/debian vivid contrib

Reference: https://www.howtoforge.com/tutorial/managing-a-headless-virtualbox-installation-with-phpvirtualbox-on-ubuntu-16.04/

Prerequisites

Add Repo

Add repo to /etc/apt/sources.list

#Virtual Box
deb http://download.virtualbox.org/virtualbox/debian jessie contrib non-free

or

#Virtual Box
deb http://download.virtualbox.org/virtualbox/debian xenial contrib

Fetch Oracle Public key

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 -

update + ugprade

apt-get update
apt-get upgrade

Installation

Virtualbox

Validate latest version at: https://www.virtualbox.org/wiki/Linux_Downloads

apt-get install virtualbox-5.1 virtualbox-dkms

Virtualbox Extension Pack

Validate latest version at: https://www.virtualbox.org/wiki/Downloads

cd /source
wget http://download.virtualbox.org/virtualbox/5.1.22/Oracle_VM_VirtualBox_Extension_Pack-5.1.22-115126.vbox-extpack

Install extension pack

VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.1.22-115126.vbox-extpack

phpvirtualbox

Prerequisites

apt-get install php-soap virtualbox-guest-utils

Download latest stable phpvirtualbox: https://sourceforge.net/projects/phpvirtualbox/

cd /source
wget http://downloads.sourceforge.net/project/phpvirtualbox/phpvirtualbox-5.0-5.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fphpvirtualbox%2F&ts=1461382116&use_mirror=heanet

Fix wget crappy naming

mv phpvirtualbox-5.0-5.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fphpvirtualbox%2F phpvirtualbox-5.0-5.zip

Unzip phpvirtualbox and move to webroot

unzip phpvirtualbox-5.0-5.zip
mv phpvirtualbox-5.0-5 /var/www/vbox

Copy config.php-example to config.php and modify to desired configuration

cp config.php-example config.php

Default login is username: admin password: admin

Password Recovery:

Rename the file recovery.php-disabled to recovery.php, navigate to it in your web browser, and follow the instructions presented.

Configure Virtualbox Headless

Reference: http://www.howtoforge.com/managing-a-headless-virtualbox-installation-with-phpvirtualbox-opensuse-12.2

First create a system user called vbox and add it to the vboxusers group:

useradd -m vbox -G vboxusers

Create a password for the vbox user:

passwd vbox

Edit /etc/default/virtualbox and put in the line

VBOXWEB_USER=vbox

Edit /var/www/vbox/config.php

Change username and password for the system host if you haven't already

/* Username / Password for system user that runs VirtualBox */
var $username = 'vbox';
var $password = 'th3p4ssw0rd';
/* SOAP URL of vboxwebsrv (not phpVirtualBox's URL) */
var $location = 'http://127.0.0.1:18083/';

Bounce web server

service lighttpd restart

Make VirtualBox Web Server a service if it isn't already. Create the following

vi /usr/lib/systemd/system/vboxweb.service

/usr/lib/systemd/system/vboxweb.service

[Unit]
Description=VirtualBox Web Service
After=network.target
 
[Service]
Type=forking
PIDFile=/run/vbox/vboxweb.pid
ExecStart=/usr/bin/vboxwebsrv --pidfile /run/vbox/vboxweb.pid --background
User=vbox
Group=vboxusers
 
[Install]
WantedBy=multi-user.target
mkdir -p /run/vbox
chown vbox:vbox /run/vbox
systemctl enable vboxweb.service
systemctl start vboxweb.service

or

systemctl enable vboxweb-service
systemctl start vboxweb-service

Browse to http://server.host/vbox/

Uninstall VBox Extension Pack

Reference: https://sourceforge.net/p/phpvirtualbox/discussion/general/thread/565b7f31/

VBoxManage extpack uninstall "Oracle VM VirtualBox Extension Pack"

Make phpvirtualbox work with VB 5.1

go to phpvirtualbox webroot:

cd ./endpoints/lib/

edit: config.php

Find and replace (comment out old, add new):

//define('PHPVBOX_VER', '5.0-5');
define('PHPVBOX_VER', '5.1-0');

create 2 symlinks:

ln -s vboxweb-5.0.wsdl vboxweb-5.1.wsdl
ln -s vboxwebService-5.0.wsdl vboxwebService-5.1.wsdl