Difference between revisions of "Phpvirtualbox"
(added current Bugs for this contrib) |
|||
(56 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
{{Languages}} | {{Languages}} | ||
+ | |||
+ | {{#vardefine:contribname| {{lc: {{#titleparts: {{BASEPAGENAME}} |1}} }} }} | ||
+ | {{#vardefine:smecontribname| smeserver-{{lc: {{#titleparts: {{BASEPAGENAME}} |1}} }} }} | ||
+ | <!-- we define the language --> | ||
+ | {{#vardefine:lang| {{lc: {{#titleparts: {{PAGENAME}} | | -1}} }} |en }} | ||
+ | |||
+ | |||
+ | {{Infobox contribs | ||
+ | |name={{#var:contribname}} | ||
+ | |image= contrib.png | ||
+ | |description_image= {{#var:contribname}} logo | ||
+ | |maintainer= | ||
+ | |licence= GPL v3 | ||
+ | |url= https://github.com/phpvirtualbox/phpvirtualbox | ||
+ | |category= virtualization | ||
+ | |tags=virtualbox | ||
+ | }} | ||
== Phpvirtualbox for SME Server == | == Phpvirtualbox for SME Server == | ||
{{Level|Medium}} | {{Level|Medium}} | ||
− | |||
=== Maintainer === | === Maintainer === | ||
− | [mailto:stephdl@de-labrusse.fr[[User:stephdl|Stephane de Labrusse aka stephdl | + | [mailto:stephdl@de-labrusse.fr][[User:stephdl|Stephane de Labrusse aka stephdl]]<br /> |
+ | |||
+ | ===Version=== | ||
+ | {{#smeversion: smeserver-phpvirtualbox}} | ||
+ | {{#smeversion: phpvirtualbox}} | ||
+ | [[Version::contrib9|stephdl]][[Has SME9::true| ]] | ||
+ | {{#smeversion: smeserver-virtualbox}} | ||
=== Description === | === 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.<br /> | 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.<br /> | ||
− | |||
− | + | === Requirements === | |
− | === | + | <tabs container=""><tab name="5.2 For SME 10"> |
+ | {{Note box|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 | ||
+ | </tab><tab name="4.3 For SME 8 and 9"> | ||
You need to install the [[VirtualBox_Repository]], the [[stephdl|Stephdl_repository]] And the [[Epel|Epel Repository]] | You need to install the [[VirtualBox_Repository]], the [[stephdl|Stephdl_repository]] And the [[Epel|Epel Repository]] | ||
{{Note box|VirtualBox is a real professional solution to virtualise Operating Systems in Linux, please Read the [https://www.virtualbox.org/manual/ virtualbox manual] if you want to use entirely all features of this software}} | {{Note box|VirtualBox is a real professional solution to virtualise Operating Systems in Linux, please Read the [https://www.virtualbox.org/manual/ virtualbox manual] if you want to use entirely all features of this software}} | ||
− | + | # 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. | + | First install the required repos<syntaxhighlight lang="bash"> |
+ | yum install smeserver-extrarepositories-virtualbox smeserver-extrarepositories-epel smeserver-extrarepositories-stephdl | ||
+ | signal-even yum-modify | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 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 | + | yum install --enablerepo=epel dkms kernel-PAE-devel |
signal-event post-upgrade; signal-event reboot | signal-event post-upgrade; signal-event reboot | ||
− | This contrib is currently held in several repositories, so the following commands will install on your smeserver. | + | This contrib is currently held in several repositories ([[VirtualBox_Repository]], and the [[stephdl|Stephdl_repository]]), so the following commands will install on your smeserver. |
yum --enablerepo=stephdl,virtualbox install smeserver-phpvirtualbox smeserver-virtualbox | yum --enablerepo=stephdl,virtualbox install smeserver-phpvirtualbox smeserver-virtualbox | ||
Line 31: | Line 70: | ||
signal-event post-upgrade; signal-event reboot | 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. | + | </tab><tab name="5.0 For SME 8 and 9"> |
− | + | {{warning box| 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<syntaxhighlight lang="bash"> | ||
+ | yum install smeserver-extrarepositories-virtualbox smeserver-extrarepositories-epel smeserver-extrarepositories-stephdl | ||
+ | signal-even yum-modify | ||
+ | </syntaxhighlight>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|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 | ||
+ | </tab> | ||
+ | </tabs> | ||
+ | |||
+ | 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. | ||
{{Tip box|You can see [[VirtualBox_4.0_on_SME_Server_v8_beta_6|the Tutorial]] hosted on our Wiki in order to learn : | {{Tip box|You can see [[VirtualBox_4.0_on_SME_Server_v8_beta_6|the Tutorial]] hosted on our Wiki in order to learn : | ||
*how to create [[VirtualBox_4.0_on_SME_Server_v8_beta_6#Creating_a_Virtual_Machinecreate| your first VM]] | *how to create [[VirtualBox_4.0_on_SME_Server_v8_beta_6#Creating_a_Virtual_Machinecreate| your first VM]] | ||
*how to automatically [[VirtualBox_4.0_on_SME_Server_v8_beta_6#Automatically_Start_Virtual_Machine|start VM with the server]] }} | *how to automatically [[VirtualBox_4.0_on_SME_Server_v8_beta_6#Automatically_Start_Virtual_Machine|start VM with the server]] }} | ||
+ | |||
+ | ===Authentication=== | ||
+ | {{Note box|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 | ||
+ | {| class="wikitable" | ||
+ | |+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''' | ||
+ | |<u>Default, with adminUser defined as admin</u> | ||
+ | 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. | ||
+ | {| class="wikitable" | ||
+ | |+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''' | ||
+ | |<u>Default:</u> 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=== | ===Kernel Upgrade=== | ||
− | After a kernel | + | 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. | ||
− | + | {{Tip box|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=== | ===Installation of Extension Pack=== | ||
− | + | {{Note box|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).<syntaxhighlight lang="bash"> | |
+ | signal-event smeserver-virtualbox-update | ||
+ | </syntaxhighlight>If you still want to install it yourself... | ||
− | wget | + | 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- | + | vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.44.vbox-extpack |
see [https://www.virtualbox.org/manual/ch08.html#vboxmanage-extpack vboxmanage-extpack] for a complete list of commands | see [https://www.virtualbox.org/manual/ch08.html#vboxmanage-extpack vboxmanage-extpack] for a complete list of commands | ||
Line 65: | Line 246: | ||
* 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. | * 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=== | ===BridgeInterface=== | ||
Line 73: | Line 253: | ||
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 | 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 [https://www.virtualbox.org/manual/ch04.html 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 === | === DB Configuration === | ||
Line 79: | Line 274: | ||
# config show phpvirtualbox | # config show phpvirtualbox | ||
− | phpvirtualbox=service | + | 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==== | ====Add a different URL==== | ||
Line 100: | Line 303: | ||
To enable your changes run these commands | To enable your changes run these commands | ||
− | + | signal-event console-save | |
− | |||
*If you want to remove completely the new url | *If you want to remove completely the new url | ||
Line 109: | Line 311: | ||
then | then | ||
− | + | signal-event console-save | |
− | |||
− | |||
− | |||
− | + | ====Access The Web Interface Remotely==== | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | === Access The Web Interface Remotely === | ||
{{Warning box|Instructions below could be a flaw in Phpvirtualbox, you should remotely access trough [[SME_Server:Documentation:FAQ:booklet#Server-Manager|SSH]] or with [[OpenVPN_Bridge|openvpn]]}} | {{Warning box|Instructions below could be a flaw in Phpvirtualbox, you should remotely access trough [[SME_Server:Documentation:FAQ:booklet#Server-Manager|SSH]] or with [[OpenVPN_Bridge|openvpn]]}} | ||
Create the following folder if it doesn't exist. | Create the following folder if it doesn't exist. | ||
Line 173: | Line 338: | ||
svc -t /service/httpd-e-smith/ | svc -t /service/httpd-e-smith/ | ||
svc -t /service/httpd-admin/ | 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 === | === Uninstall === | ||
Line 184: | Line 395: | ||
To optimize and/or fine-tune your SME guest server running on your phpvirtualbox host, please see our [[Virtual_SME_Server#SME_Server_configuration_settings|Virtual SME Server wiki page]] | To optimize and/or fine-tune your SME guest server running on your phpvirtualbox host, please see our [[Virtual_SME_Server#SME_Server_configuration_settings|Virtual SME Server wiki page]] | ||
− | For general information on how to configure phpvirtualbox guests please visit the [https://www.virtualbox.org/manual/ch03.html | + | For general information on how to configure phpvirtualbox guests please visit the [https://www.virtualbox.org/manual/ch03.html phpvirtualbox documentation] |
+ | ===Bugs=== | ||
+ | Please raise bugs under the SME-Contribs section in [http://bugs.contribs.org/enter_bug.cgi bugzilla] | ||
+ | and select the smeserver-phpvirtualbox component or use {{BugzillaFileBug|product=SME%20Contribs|component=smeserver-phpvirtualbox|title=this link}} | ||
+ | Below is an overview of the current issues for this contrib:{{#bugzilla:columns=id,product,version,status,summary|sort=id|order=desc|component=smeserver-phpvirtualbox|noresultsmessage=No open bugs found.}} | ||
[[Category: Contrib]] | [[Category: Contrib]] | ||
[[Category:Virtualisation]] | [[Category:Virtualisation]] |
Latest revision as of 23:11, 12 July 2023
phpvirtualbox logo | |
Url | https://github.com/phpvirtualbox/phpvirtualbox |
---|---|
Licence | GPL v3 |
Category | |
Tags | virtualbox |
Phpvirtualbox for SME Server
Maintainer
[1]Stephane de Labrusse aka stephdl
Version
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
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
- Installation phpvirtualbox-4.3 For SME8 and SME9
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
First install the required repos
yum install smeserver-extrarepositories-virtualbox smeserver-extrarepositories-epel smeserver-extrarepositories-stephdl
signal-even yum-modify
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.
Authentication
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
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
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.
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.
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
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
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
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:
ID | Product | Version | Status | Summary (3 tasks) ⇒ |
---|---|---|---|---|
12341 | SME Contribs | 10.0 | CONFIRMED | httpd error whilst using group access via WebAuth |
12337 | SME Contribs | 10.0 | IN_PROGRESS | samba access should be configurable |
12336 | SME Contribs | 10.0 | IN_PROGRESS | samba browsing to ISO directory not working |