Difference between revisions of "PhpVirtualBox"

From ArchWiki
Jump to: navigation, search
(make article less.. less.)
(tried to improve article a bit, please review)
Line 1: Line 1:
 
[[Category:Virtualization]]
 
[[Category:Virtualization]]
  
phpVirtualBox is 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. Much of its verbage and some of its code is based on the (inactive) vboxweb project. phpVirtualBox was designed to allow users to administer VirtualBox in a headless environment - mirroring the VirtualBox GUI through its web interface.  
+
'''phpVirtualBox''' is 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. Much of its verbage and some of its code is based on the (inactive) vboxweb project. phpVirtualBox was designed to allow users to administer VirtualBox in a headless environment - mirroring the VirtualBox GUI through its web interface.  
  
 
== Installation ==
 
== Installation ==
To remotely control virtual machine you need two components: VirtualBox web service, running in the same OS with virtual machine, and web interface, written in PHP and therefore dependent on PHP-capable web server. Communication between them, based on [[Wikipedia:SOAP|SOAP]] protocol is currently unencrypted, so it is recommended to both on the same machine if you do not want your username and password to be send via network as clear text.
+
To remotely control virtual machine you need two components: VirtualBox web service, running in the same OS with virtual machine, and web interface, written in PHP and therefore dependent on PHP-capable web server. Communication between them, based on [[Wikipedia:SOAP|SOAP]] protocol is currently unencrypted, so it is recommended to install both on the same machine if you do not want your username and password to be send via network as clear text.
  
 
=== VirtualBox web service ===
 
=== VirtualBox web service ===
Line 13: Line 13:
  
 
== Configuration ==
 
== Configuration ==
=== PHPVirtualBox 4.0+ ===
+
''From here on out, it is assumed that you have a web server (with root at {{Ic|/srv/http}}) and php functioning properly.''
  
First we have some prerequisites. php, virtualbox, phpvirtualbox, unzip, and a webserver of your choosing. I run apache so adjust accordingly.  
+
=== Web service ===
 +
In virtual machine settings, enable the remote desktop access and specify a port different with other virtual machines.
  
From here on out, I assume you have a web server (with root at /srv/http) and php functioning properly.
+
Every time you need to make machine remotely available execute something like this:
  
Uncomment the 'extension=soap.so' line in /etc/php/php.ini using your favorite text editor. Don't forget to restart the webserver.
+
vboxwebsrv -b --logfile '''path to log file''' --pidfile /run/vbox/vboxwebsrv.pid --host 127.0.0.1
  
{{Ic|rc.d restart httpd}}
+
As user whom account you want service to be running from ({{Ic|--host}} option is not necessary if you enabled association with '''localhost''' in the {{Ic|/etc/host.conf}}).
  
Move into the directory you want the webserver to point to (again /srv/http for me)
+
{{Note|This user must be in group '''vboxusers'''!}}
  
{{Ic|cd /srv/http}}
+
If Oracle-distributed binary edition of VirtualBox, available with AUR package {{AUR|virtualbox_bin}} there is already a '''vboxweb''' daemon script, which you can use by placing {{Ic|vboxweb.conf}} into {{Ic|/etc/conf.d}} and {{Ic|vboxweb.rc}} into {{Ic|/etc/rc.d}} (in the {{Ic|/etc/conf.d/vboxweb}}, you should take care of '''VBOXWEB_USER''' variable which should be set to the system username running the the {{Ic|vboxwebsrv}} command).
  
Download the latest version of phpvirtualbox from their website. At this writing it is 4.1.7. 
+
=== Web interface ===
         
+
Edit {{Ic|/etc/php/php.ini}}, make sure the following lines are uncommented.
{{Ic|wget `wget -q -O - http://phpvirtualbox.googlecode.com/files/LATEST.txt` -O phpvirtualbox-latest.zip}}
+
  
Extract the archive
+
extension=json.so
 +
extension=soap.so
  
{{Ic|unzip phpvirtualbox-latest.zip}}
+
Don't forget to restart the webserver like this (example for Apache):
  
Change the location from the extracted folder to whatever name you want. Unless configured otherwise, this will be in the address line.
+
{{Ic|rc.d restart httpd}}
  
{{Ic|mv phpvirtualbox-latest phpvirtualbox}
+
Edit the example configuration file {{Ic|/usr/share/webapps/phpvirtualbox/config.php-example}} appropriately (it is well-commented and does not need explanations). Copy that file into {{Ic|/etc/webapps/phpvirtualbox/config.php}}, {{Ic|/usr/share/webapps/phpvirtualbox/config.php}} and {{Ic|/usr/share/webapps/phpvirtualbox/lib/config.php}}.
  
Jump into that directory to do some editing
+
If you are running Apache as webserver, you can copy {{Ic|/etc/webapps/phpvirtualbox/apache.example.conf}} into {{Ic|/etc/httpd/conf/extra/phpvirtualbox.conf}}, and then add following line into {{Ic|/etc/httpd/conf/httpd.conf}}:
  
{{Ic|cd phpvirtualbox}}
+
Include conf/extra/phpvirtualbox.conf
  
Edit the example configuration. Save as config.php
+
Edit {{Ic|/etc/webapps/phpvirtualbox/.htaccess}} and remove the following line.
 
+
{{Ic|nano config.php-example}}
+
 
+
Copy that file into:
+
 
+
{{Ic|/etc/webapps/phpvirtualbox/config.php}}
+
 
+
{{Ic|/usr/share/webapps/phpvirtualbox/config.php}}
+
 
+
{{Ic|/usr/share/webapps/phpvirtualbox/lib/config.php}}
+
 
+
Change the username & password. (note these are not the login credentials)
+
 
+
Run vboxwebsrv as whatever user you put in the config.php file
+
 
+
Go to http://host/phpvirtualbox
+
 
+
Login using "admin" "admin" for username and password.
+
 
+
Go to File -> change password. Change the password.
+
 
+
=== VirtualBox Web Service ===
+
{{Out of date}}
+
 
+
If you are using the OSE edition, do something like this on your virtualbox running machine.
+
 
+
vboxwebsrv -b --logfile /dev/null --pidfile /var/run/vbox/vboxwebsrv.pid --host 127.0.0.1
+
 
+
If you are using the UEL edition, there is already a vboxweb script in {{Ic|/etc/rc.d}}, what you need is adjusting the settings in {{Ic|/etc/conf.d/vboxweb}} and then start it like the other daemon.
+
 
+
For OSE users, you can also use these scripts form UEL edition package, just put the {{Ic|vboxweb.conf}} into {{Ic|/etc/conf.d}} and the {{Ic|vboxweb.rc}} into {{Ic|/etc/rc.d}}, you can get them from the {{AUR|virtualbox_bin}}.
+
 
+
In the {{Filename|/etc/conf.d/vboxweb}}, you should take care of '''VBOXWEB_USER''' variable which should be set to the system username running the the {{Ic|vboxwebsrv}} command.
+
 
+
Check that this user is in group '''vboxusers'''.
+
 
+
=== VirtualBox Web Interface ===
+
 
+
Edit {{Ic|/etc/webapps/phpvirtualbox/config.php}}
+
 
+
1. Change the following lines into the system username you previously set in {{Filename|/etc/conf.d/vboxweb}} as well as its password. (Yes,for now, it is clear password here, maybe this could be changed in a future release.)
+
 
+
var $username = '';
+
var $password = '';
+
 
+
2. Change the following line into the ip address and the port your vboxwebsrv is running and listening. For most installations, it should be localhost and tcp port 18083. It is recommended to install your virtualbox web service and the virtualbox web interface on the same machine, because the username and the password you previously set is passing as the clear text.
+
 
+
var $location = 'http://127.0.0.1:18083/';
+
 
+
3. If you do not want to use authentication, you can uncomment the following line.
+
 
+
#var $noAuth = true;
+
 
+
Edit {{Filename|/etc/webapps/phpvirtualbox/.htaccess,comment}} or remove the following line.
+
  
 
  deny from all
 
  deny from all
 
Edit {{Filename|/etc/php/php.ini}}, make sure the following lines is uncommented.
 
 
extension=json.so
 
extension=soap.so
 
 
If you are running apache as webserver, you can copy {{Filename|/etc/webapps/phpvirtualbox/apache.example.conf}} into {{Filename|/etc/httpd/conf/extra/phpvirtualbox.conf}}, and then add following line into {{Filename|/etc/httpd/conf/httpd.conf}}
 
 
Include conf/extra/phpvirtualbox.conf
 
 
To use the web console, you should install the [http://aur.archlinux.org/packages.php?ID=44761 virtualbox-ext-oracle] package from AUR, and then change the virtual machine setting, enable the remote desktop access on display panel and specify an port different with other virtual machines.
 
  
 
== Running ==
 
== Running ==
If everything works fine, visit http://YourVboxWebInterfaceServer/phpvirtualbox and it should show a login box. The initial username and password are both admin, but after login, you can change your password and control users from the web interface. If you set {{Ic|$noAuth=true}} in the {{Ic|config.php}}, you should immediately see the phpvirtualbox web interface.
+
If everything works fine, visit http://'''YourVboxWebInterfaceHost'''/phpvirtualbox and it should show a login box. The initial username and password are both '''"admin"''', after login change them from the web interface (File -> change password). If you set {{Ic|1=$noAuth=true}} in the web interface {{Ic|config.php}}, you should immediately see the phpvirtualbox web interface.
  
 
== Debugging ==
 
== Debugging ==

Revision as of 05:54, 25 January 2012


phpVirtualBox is 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. Much of its verbage and some of its code is based on the (inactive) vboxweb project. phpVirtualBox was designed to allow users to administer VirtualBox in a headless environment - mirroring the VirtualBox GUI through its web interface.

Installation

To remotely control virtual machine you need two components: VirtualBox web service, running in the same OS with virtual machine, and web interface, written in PHP and therefore dependent on PHP-capable web server. Communication between them, based on SOAP protocol is currently unencrypted, so it is recommended to install both on the same machine if you do not want your username and password to be send via network as clear text.

VirtualBox web service

To use the web console, you must install virtualbox-ext-oracleAUR package from AUR.

VirtualBox web interface (phpvirtualbox)

Install phpvirtualbox from Official Repositories on a php-capable web server of your choise (Apache is suitable choice).

Configuration

From here on out, it is assumed that you have a web server (with root at /srv/http) and php functioning properly.

Web service

In virtual machine settings, enable the remote desktop access and specify a port different with other virtual machines.

Every time you need to make machine remotely available execute something like this:

vboxwebsrv -b --logfile path to log file --pidfile /run/vbox/vboxwebsrv.pid --host 127.0.0.1

As user whom account you want service to be running from (--host option is not necessary if you enabled association with localhost in the /etc/host.conf).

Note: This user must be in group vboxusers!

If Oracle-distributed binary edition of VirtualBox, available with AUR package virtualbox_binAUR there is already a vboxweb daemon script, which you can use by placing vboxweb.conf into /etc/conf.d and vboxweb.rc into /etc/rc.d (in the /etc/conf.d/vboxweb, you should take care of VBOXWEB_USER variable which should be set to the system username running the the vboxwebsrv command).

Web interface

Edit /etc/php/php.ini, make sure the following lines are uncommented.

extension=json.so
extension=soap.so

Don't forget to restart the webserver like this (example for Apache):

rc.d restart httpd

Edit the example configuration file /usr/share/webapps/phpvirtualbox/config.php-example appropriately (it is well-commented and does not need explanations). Copy that file into /etc/webapps/phpvirtualbox/config.php, /usr/share/webapps/phpvirtualbox/config.php and /usr/share/webapps/phpvirtualbox/lib/config.php.

If you are running Apache as webserver, you can copy /etc/webapps/phpvirtualbox/apache.example.conf into /etc/httpd/conf/extra/phpvirtualbox.conf, and then add following line into /etc/httpd/conf/httpd.conf:

Include conf/extra/phpvirtualbox.conf

Edit /etc/webapps/phpvirtualbox/.htaccess and remove the following line.

deny from all

Running

If everything works fine, visit http://YourVboxWebInterfaceHost/phpvirtualbox and it should show a login box. The initial username and password are both "admin", after login change them from the web interface (File -> change password). If you set $noAuth=true in the web interface config.php, you should immediately see the phpvirtualbox web interface.

Debugging

If you encounter a login problem, and you are upgrade your virtualbox from 3.2.x to 4.0.x, you should run the following command to update you websrvauthlibrary in you virtualbox configuration file which has been changed from VRDPAuth.so to VBOXAuth.so.

VBoxManage setproperty vrdeauthlibrary default
VBoxManage setproperty websrvauthlibrary default 

If you are still unable to login into the interface, you can try to disable webauth by

VBoxManage setproperty websrvauthlibrary null

on virtualization server and set username and password to empty strings and set $noAuth=true in Template:Filename on web server. By doing this, you should immediatelly access the web interface without login process. And then, maybe you can try some apache access control.

External Resources