Phpvirtualbox
Phpvirtualbox for SME Server
Maintainer
Stephane de Labrusse aka stephdl
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
You need to install the VirtualBox_Repository, the Stephdl_repository And the Epel Repository
Installation phpvirtualbox-4.3 For SME8 and SME9
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 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
Go to the phpvirtualbox panel at the url https://your-sme-ip/phpvirtualbox on your local-network. You can not reach this contrib trought internet. Your credentials are the user admin of the SME Server and its password but you can add more users by the DB Configuration.
Installation phpvirtualbox-5.0 For SME8 and SME9
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 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 internet. Your credentials are the user admin of the SME Server and its password but you can add more users by the DB Configuration.
Restart the vboxweb-service
phpvirtualbox controls a virtualbox service (vboxweb-service), you may need to restart it if you can't connect to phpvirtualbox
/etc/init.d/vboxweb-service restart
you can control eventually 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 need to be compiled with the new kernel, a script is launched at the boot time to test if the compilation is needed.
You can see if all kernel modules are compiled and loaded, if you issue :
# /etc/init.d/vboxdrv status VirtualBox kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) are loaded.
/etc/init.d/vboxdrv setup; /etc/init.d/vboxweb-service start
Stopping VirtualBox kernel modules [ OK ] Uninstalling old VirtualBox DKMS kernel modules [ OK ] Trying to register the VirtualBox kernel modules using DKMS[ OK ] Starting VirtualBox kernel modules [ OK ]
Installation of Extension Pack
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 to download the extension pack if the url below is no longer good.
For example :
wget http://dlc.sun.com.edgesuite.net/virtualbox/4.3.0/Oracle_VM_VirtualBox_Extension_Pack-4.3.0-89960.vbox-extpack vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.0-89960.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 Group= Name=phpvirtualbox User= status=enabled webauth=enabled
# config show vboxweb-service vboxweb-service=service TCPPort=18083 access=localhost status=enabled
Add a different URL
by example
http://yourserver.net/VB
or
http://yourserver.net/PVB
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
Web authentication
you can allow web authentication to phpvirtualbox by doing the command line below. This feature is the default behaviour since the bug opened is solved http://sourceforge.net/p/phpvirtualbox/bugs/7/.
config setprop phpvirtualbox webauth enabled signal-event console-save
and you have to modify manually the file config.php
nano /opt/phpvirtualbox/config.php
// Authentication library. var $authLib = 'Builtin'; #var $authLib = 'WebAuth'; #var $authConfig = array('adminUser' => 'admin');
to
// Authentication library. #var $authLib = 'Builtin'; var $authLib = 'WebAuth'; var $authConfig = array('adminUser' => 'admin');
Allow Specific Users
The users must be declared and a password must be set in the server-manager.
config setprop phpvirtualbox User user1,user2,user3 signal-event console-save
Allow Specific Groups
These groups must be declared in the server-manager and users need to be included
config setprop phpvirtualbox Group Group1,Group2,Group3 signal-event console-save
Access The Web Interface Remotely
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