Phpvirtualbox

From SME Server
(Redirected from Smeserver-virtualbox)
Jump to navigationJump to search







phpvirtualbox
NeedImage.svg
phpvirtualbox logo
Urlhttps://github.com/phpvirtualbox/phpvirtualbox
LicenceGPL v3
Category

virtualization

Tags virtualbox


Phpvirtualbox for SME Server

PythonIcon.png Skill level: Medium
The instructions on this page require a basic knowledge of linux.


Maintainer

[1]Stephane de Labrusse aka stephdl

Version

Devel 10:
smeserver-phpvirtualbox
The latest version of smeserver-phpvirtualbox is available in the SME repository, click on the version number(s) for more information.


Update 10:
phpvirtualbox
The latest version of phpvirtualbox is available in the SME repository, click on the version number(s) for more information.


stephdl

Devel 10:
smeserver-virtualbox
The latest version of smeserver-virtualbox is available in the SME repository, click on the version number(s) for more information.


Description

An open source, AJAX implementation of the VirtualBox user interface written in PHP. As a modern web interface, it allows you to access and control remote VirtualBox instances. phpVirtualBox is designed to allow users to administer VirtualBox in a headless environment - mirroring the VirtualBox GUI through its web interface.

Requirements

Important.png Note:
work in progress, alpha, use at your own risks

Please make sure you have the latest kernel installed (i.e. do a yum update) before installing, so that we use the right kernel headers for compiling the driver

This will install phpvirtualbox and the appropriate version of smeserver-virtualbox and VirtualBox, which will compile it's drivers, so we need to install a few development components as well

yum install smeserver-extrarepositories-epel smeserver-extrarepositories-virtualbox
yum --enablerepo=smedev,smecontribs,epel,virtualbox  install smeserver-phpvirtualbox

The install will prompt you to accept the VirtualBox GPG key

You need to install the VirtualBox_Repository, the Stephdl_repository And the Epel Repository


Important.png Note:
VirtualBox is a real professional solution to virtualise Operating Systems in Linux, please Read the virtualbox manual if you want to use entirely all features of this software

  1. Installation phpvirtualbox-4.3 For SME8 and SME9
First install the required repos
yum install smeserver-extrarepositories-virtualbox smeserver-extrarepositories-epel smeserver-extrarepositories-stephdl
signal-even yum-modify

You have to be sure that your server has the kernel up-to-date before to install virtualbox, else the installation will fail. You must first configure the epel repository

yum install --enablerepo=epel dkms kernel-devel
signal-event post-upgrade;  signal-event reboot

For PAE Kernel you have to install kernel-PAE-devel in order to be compiled with DKMS

yum install --enablerepo=epel dkms kernel-PAE-devel
signal-event post-upgrade;  signal-event reboot

This contrib is currently held in several repositories (VirtualBox_Repository, and the Stephdl_repository), so the following commands will install on your smeserver.

yum --enablerepo=stephdl,virtualbox  install smeserver-phpvirtualbox smeserver-virtualbox

You will then need to activate the database changes and to reboot with the new kernel module loaded.

signal-event post-upgrade;  signal-event reboot
Warning.png Warning:
You have to remove first all old rpm before to install phpvirtualbox-5.0 and VirtualBox-5.0, this is done by the different version of virtualbox (the version 5.0 doesn't obsolete the 4.3 version)
yum remove smeserver-phpvirtualbox\* smeserver-virtualbox\* VirtualBox\* phpvirtualbox\* dkms

First install the required repos
yum install smeserver-extrarepositories-virtualbox smeserver-extrarepositories-epel smeserver-extrarepositories-stephdl
signal-even yum-modify
You have to be sure that your server has the kernel up-to-date before to install virtualbox, else the installation will fail. You must first configure the epel repository
yum install --enablerepo=epel dkms kernel-devel
signal-event post-upgrade;  signal-event reboot

For PAE Kernel you have to install kernel-PAE-devel in order to be compiled with DKMS

yum install --enablerepo=epel dkms kernel-PAE-devel
signal-event post-upgrade;  signal-event reboot

This contrib is currently held in several repositories (VirtualBox_Repository, and the Stephdl_repository), so the following commands will install on your smeserver.

yum --enablerepo=stephdl,virtualbox  install smeserver-phpvirtualbox-5.0 smeserver-virtualbox-5.0

You will then need to activate the database changes and to reboot with the new kernel module loaded.

signal-event post-upgrade;  signal-event reboot

Go to the phpvirtualbox panel at the url https://your-sme-ip/phpvirtualbox on your local-network. You can not reach this contrib trought the internet.

The only user with access at this stage is your SME Server admin user. See Authentication below on how to change this.


Information.png Tip:
You can see the Tutorial hosted on our Wiki in order to learn :


Authentication

Important.png Note:
Authentication is still being worked on, but mostly works as advertised.


you can allow authentication to phpvirtualbox via number of methods. At install, default is WebAuth with admin defined as the adminUser.

config setprop phpvirtualbox authtype <none/Builtin/LDAP/WebAuth/AD>
signal-event smeserver-phpvirtualbox-update
config setprop phpvirtualbox authtype <none/Builtin/LDAP/WebAuth/AD>
Property Description adminUser Users userGroups
none everyone on your local network has access, without needing to log in ignored ignored ignored
BuiltIn will use the phpvirtualbox builtin authentication which lets you manage users within phpvirtualbox ONLY.

Default admin user is admin with password admin (this is a phpvirtualbox thing....)

It does NOT have any interface/interaction with smeserver users

ignored ignored ignored
LDAP will allow any smeserver user access, with whomever is defined in the phpvirtualbox adminUser config item as the administrator administrative rights ignored ignored
WebAuth Default, with adminUser defined as admin

will allow any user defined in the phpvirtualbox Users config item, or belonging to groups defined in the phpvirtualbox userGroups config items

Admin access is defined by the phpvirtualbox adminUser config item

(Note: using group access will generate lots of errors in the /var/log/httpd/error.log file ATM).

administrative rights user rights user rights
AD is defined, but has not been tested.

will allow any user defined in the phpvirtualbox Users config item, or belonging to AD groups defined in the phpvirtualbox userGroups config items access.

Admin access is defined by the phpvirtualbox adminUser config item

administrative rights user rights user rights
Allow Specific Users

Works with WebAuth and AD

The users must be declared and a password must be set in the server-manager.

config setprop phpvirtualbox Users user1,user2,user3
signal-event smeserver-phpvirtualbox-update
Allow Specific Groups

Works with WebAuth and AD

These groups must be declared in the server-manager and users need to be members of the group/s

config setprop phpvirtualbox userGroups Group1,Group2,Group3
signal-event smeserver-phpvirtualbox-update

Access the ISO share directory via samba

This is where ISOs used for building/installing VMs are stored.

By default, anyone defined in adminUser, Users or userGroups will have write access to the /opt/vbox/ISOs directory (share name virtualbox), regardless of the authtype.

You can control whether the share is available/visible and who has access via the phpvirtualbox samba configuration item.

config setprop phpvirtualbox samba <none/adminUser/all>
Property Description
none No share created or visible
adminUser ONLY user defined in adminUser, has write access to virtualbox share
all Default: Any user defined in adminUser, Users or userGroups has write access to the virtualbox share

Restart the vboxweb-service

phpvirtualbox controls a virtualbox service (vboxweb-service), you may need to restart it if you can't connect to phpvirtualbox

systemctl restart vboxweb-service

you can check that the port 18083 is opened to the service

nmap localhost -p 18083
....
PORT      STATE SERVICE
18083/tcp open  unknown

or

netstat -a | grep vboxweb-service
tcp        0      0 localhost:vboxweb-service   *:*                         LISTEN

Kernel Upgrade

After a kernel upgrade and the "signal-event post-upgrade; signal-event reboot", the vboxdrv needs to be compiled with the new kernel, a script is launched at startup of the driver, to test if the compilation is needed and will compile it for you.

You can see if all the kernel modules are compiled and loaded, if you issue :

# /usr/lib/virtualbox/vboxdrv.sh status
VirtualBox kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) are loaded.


Information.png Tip:
Restarting the vboxdrv service will trigger a driver compile if it is not present.

If you want to manually launch the compilation of virtualbox module you can run the driver setup script.


Run the driver setup script and restart the vbox web service

/usr/lib/virtualbox/vboxdrv.sh setup; systemctl restart vboxweb-service

Installation of Extension Pack

Important.png Note:
The Extension Pack provides support for USB 2.0 devices, VirtualBox RDP and PXE boot for Intel cards. See this chapter from the User Manual for an introduction to this Extension Pack.

See this page (https://www.virtualbox.org/wiki/Downloads) to download the extension pack if the url below is no longer good.


The Extension Pack is now automatically installed with VirtualBox.

You can trigger a re-check, and possible install. This will also check the installed driver and recompile if required (e.g. after a kernel upgrade).

signal-event smeserver-virtualbox-update

If you still want to install it yourself...

wget https://download.virtualbox.org/virtualbox/5.2.44/Oracle_VM_VirtualBox_Extension_Pack-5.2.44.vbox-extpack
vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.44.vbox-extpack

see vboxmanage-extpack for a complete list of commands

  • To add a new extension pack, use VBoxManage extpack install <.vbox-extpack>. This command will fail if an older version of the same extension pack is already installed. The optional --replace parameter can be used to uninstall the old package before the new package is installed.
  • To remove a previously installed extension pack, use VBoxManage extpack uninstall <name>. You can use VBoxManage list extpacks to show the names of the extension packs which are currently installed. The optional --force parameter can be used to override the refusal of an extension pack to be uninstalled.
  • The VBoxManage extpack cleanup command can be used to remove temporary files and directories that may have been left behind if a previous install or uninstall command failed.

BridgeInterface

smeserver-bridge-interface is a small package allowing you to bridge your Internal Interface with one or more virtual tap interfaces. It's main goal is to be used with the new OpenVPN-Bridge contrib, but it has been split in another contrib as it can be used in other situations (if you want to run a virtual machine on your SME Server with virtualbox for example).

see BridgeInterface

Therefore your Guest O.S will have a real ip on your local network, you need to set its virtual NIC on bridged adapter (br0) in phpvirtualbox network settings

VirtualBox Guest Additions

For any serious and interactive use, the VirtualBox Guest Additions will make your life much easier by providing closer integration between host and guest and improving the interactive performance of guest systems. see this link for more informations

You have to enable the epel repository and to insert the guest additions cd images in phpvirtualbox.

yum install gcc kernel-devel dkms --enablerepo=epel
mkdir /media/cdrom
mount -t iso9660 /dev/cdrom /media/cdrom/
sh /media/cdrom/VBoxLinuxAdditions.run
ln -s ../init.d/vboxadd /etc/rc7.d/S30vboxadd
signal-event post-upgrade; signal-event reboot

DB Configuration

configuration database

# config show phpvirtualbox 
phpvirtualbox=configuration
    Name=phpvirtualbox
    adminUser=admin
    authtype=WebAuth
    status=enabled
    userGroups=vboxusers
# config show vboxweb-service 
vboxweb-service=service
    TCPPort=18083
    access=localhost
    password=<generated password>
    status=enabled
    user=vbox

Add a different URL

by example

http://yourserver.net/VB 

or

http://yourserver.net/PVB


Important.png Note:
this adds another url, it doesn't remove the default


config setprop phpvirtualbox URL VB

or

config setprop phpvirtualbox URL PVB

To enable your changes run these commands

signal-event console-save
  • If you want to remove completely the new url
config delprop phpvirtualbox URL

then

signal-event console-save

Access The Web Interface Remotely

Warning.png Warning:
Instructions below could be a flaw in Phpvirtualbox, you should remotely access trough SSH or with openvpn


Create the following folder if it doesn't exist.

mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/

Copy the file 92phpvirtualhost to the newly created folder.

cp /etc/e-smith/templates/etc/httpd/conf/httpd.conf/92phpvirtualhost /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/

Edit the file and add your public IP address.

nano /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/92phpvirtualhost

Change the line:

$OUT .= "    allow from $localAccess\n";

to the one below (eg. 123.456.789.012 is your public IP address) then save the file.

$OUT .= "    allow from $localAccess 123.456.789.012\n";
expand-template /etc/httpd/conf/httpd.conf
svc -t /service/httpd-e-smith/
svc -t /service/httpd-admin/

Autostart Virtual Machines

Once you have one or more virtual machines installed and running, you may want them to start automatically on system boot. To do this, you will need to stop the virtual machines in question, create one configuration file, edit another, and set some properties using the VBoxManage utility.

Stop the virtual machines

Using the phpVirtualBox web interface, power down or save state the virtual machine(s) you want to set to start automatically. Alternatively, log in to those virtual machines and shut them down. Confirm in the phpVirtualBox web interface that the status is not "Running".

Create /etc/vbox/autostart.cfg

[root@e-smith ~]# nano -w /etc/vbox/autostart.cfg 

Add the following to this file:

# Default policy is to deny starting a VM, the other option is "allow".
default_policy = deny

# Create an entry for each user allowed to run autostart
root = {
allow = true
}

Edit /etc/default/virtualbox

[root@e-smith ~]# nano -w /etc/default/virtualbox

Add these two lines:

VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg

Using VBoxManage to set properties

First, tell VirtualBox where your autostart configuration is:

[root@e-smith ~]# VBoxManage setproperty autostartdbpath /etc/vbox

Next, use VBoxManage to list your installed virtual machines:

[root@e-smith ~]# VBoxManage list vms
"Elastix 3.0.0-RC1" {6259ddda-888d-43e9-9364-25867668d889}
"PIAF 3" {69d75c64-4cfe-4023-a4a2-b2b39a442746}
"IncrediblePBX 12" {e7e4845b-8178-4e87-aceb-7f2a78c77977}
"Ubuntu 14.04.1 LTS" {6094a7e0-5b3c-4cc3-b8c8-f55a9716318b}
"Asterisk-GUI" {19d53974-512b-443b-8fd9-aff80c207bd9}
"Windows 7" {df3d3440-3113-4c91-9890-5323f99d755c}

Then, set your desired virtual machines to start automatically, with an optional delay, and optionally to suspend (rather than power down) when your SME server shuts down or reboots. You can specify the virtual machine by name or by UUID:

[root@e-smith ~]# VBoxManage modifyvm "IncrediblePBX 12" --autostart-enabled on --autostart-delay 15
[root@e-smith ~]# VBoxManage modifyvm df3d3440-3113-4c91-9890-5323f99d755c --autostart-enabled on --autostop-type savestate

Finally, start the vboxautostart-service service:

[root@e-smith ~]# service vboxautostart-service start

or

[root@e-smith ~]# /etc/init.d/vboxautostart-service start

Confirm that the desired virtual machines are running in the phpVirtualBox web interface.

Uninstall

yum remove smeserver-virtualbox smeserver-phpvirtualbox phpvirtualbox VirtualBox-4.3 dkms

Bugs

Please raise bugs under the SME-Contribs section in bugzilla and select the smeserver-phpvirtualbox component or use this link .

SME guest server configuration

To optimize and/or fine-tune your SME guest server running on your phpvirtualbox host, please see our Virtual SME Server wiki page

For general information on how to configure phpvirtualbox guests please visit the phpvirtualbox documentation

Bugs

Please raise bugs under the SME-Contribs section in bugzilla and select the smeserver-phpvirtualbox component or use this link


Below is an overview of the current issues for this contrib:

IDProductVersionStatusSummary (3 tasks)
12341SME Contribs10.0CONFIRMEDhttpd error whilst using group access via WebAuth
12337SME Contribs10.0IN_PROGRESSsamba access should be configurable
12336SME Contribs10.0IN_PROGRESSsamba browsing to ISO directory not working