My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
MultipleServerConfiguration  
Multiple server configuration example.
Manual
Updated Mar 12, 2011 by imooreya...@gmail.com

Basic Multiple server configuration of phpVirtualBox

Starting with phpVirtualBox 4-0, phpVirtualBox can be configured to interact with multiple VirtualBox installations. Provided that each is running its own vboxwebsrv instance. To do this, edit config.php in phpVirtualBox's folder and locate the following code:

/*
var $servers = array(
	array(
		'name' => 'London',
		'username' => 'user',
		'password' => 'pass',
		'location' => 'http://192.168.1.1:18083/'
	),
	array(
		'name' => 'New York',
		'username' => 'user2',
		'password' => 'pass2',
		'location' => 'http://192.168.1.2:18083/'
	),
);
*/

Uncomment the code (remove the /* and */) and edit the server values. An example config may look like this:

var $servers = array(
	array(
		'name' => 'London',
		'username' => 'vbox',
		'password' => 'secret1',
		'location' => 'http://10.32.32.4:18083/'
	),
	array(
		'name' => 'New York',
		'username' => 'vboxadmin',
		'password' => 'secret2',
		'location' => 'http://10.32.45.2:18083/'
	),
);

Note that the server names may be anything you wish. These should be descriptive to you.

Once this is done, you may change servers by clicking on the server name in the top item of the virtual machine list. The resulting menu will allow you to specify which server phpVirtualBox will communicate with.

Multiple servers and Authentication

Basic user authentication was introduced in phpVirtualBox 4.0-4. phpVirtualBox stores its usernames and passwords in the VirtualBox server. This can only use ONE VirtualBox server for authentication. By default, it will use the first server in the $servers list. If you would like to change this, you can add an 'authMaster' property set to true to one of the servers. An example my look like:

var $servers = array(
	array(
		'name' => 'London',
		'username' => 'vbox',
		'password' => 'secret1',
		'location' => 'http://10.32.32.4:18083/'
	),
	array(
		'name' => 'New York',
		'username' => 'vboxadmin',
		'password' => 'secret2',
		'location' => 'http://10.32.45.2:18083/',
                'authMaster' => true
	),
);

One important implication of this is that phpVirtualBox will only be accessible if the authentication server is up - either the fist one in the list, or the one with the authMaster property. In a bind, you may turn off authentication by adding the following line to config.php:

var $noAuth = true;

Advanced Multiple Server Configuration

Any settings available in phpVirtualBox's config.php can be also be added to a server configuration. E.g.

var $servers = array(
	array(
		'name' => 'London',
		'username' => 'vbox',
		'password' => 'secret1',
		'location' => 'http://10.32.32.4:18083/',
                'consoleHost' => '10.32.32.4',
                'noPreview' => true,
                'browserRestrictFolders' => array('/home/vbox','/mnt/media')

	),
	array(
		'name' => 'New York',
		'username' => 'vboxadmin',
		'password' => 'secret2',
		'location' => 'http://10.32.45.2:18083/',
                'consoleHost' => '10.32.45.2',
                'browserRestrictFolders' => array('/home/vboxadmin','/var/isos')
	),
);
Comment by dave@boostpro.com, Jan 26, 2011

Could you add some notes explaining what the main advantage over running phpVirtualBox on each server is? Thanks!

Comment by project member imooreya...@gmail.com, Jan 27, 2011

A couple administrative advantages:

  • You could manage your VirtualBox? installations through one URL.
  • You only have to worry about updating one phpVirtualBox install when new versions are released.

Other than that, it is no different.

Comment by diazleon...@gmail.com, Feb 12, 2011

Other important advantage is that you don't need to have apache/php running in your vbox server. Less load and more secure.

Comment by project member imooreya...@gmail.com, Mar 31, 2011

Yes, please use the issues tab.

Comment by mrlit...@gmail.com, Jun 22, 2011

Please note that AFAIK, there is no way to get vboxwebsvr to listen on multiple interfaces. This can cause issues if you want to refer to all of your hypervisors by their hostname and not have hardcoded ip addresses. In my case, all of my Hypervisors were registered in DNS and hostname lookups were working.

Take this example:

cat /etc/vbox/vbox.cfg
VBOXWEB_USER=vbox
VBOXWEB_HOST=hv01

If I use that in config.php in phpvirtualbox, it has no problem contacting that vboxwebsvr if phpvirtualbox is running on the same server:

var $username = vbox';
var $password = password';
var $location = 'http://hv01:18083/';  

However, if I try to configure multi-site phpvirtualbox on another hypervisor, hv02, and connect to hv01 using the hostname, it doesn't work. In fact, checking the port from another host will show the port is closed:

hv02$> nc -vz hv01 18083
nc: connect to hv01 port 18083 (tcp) failed: Connection refused

The setup works flawlessly when I hardcode ip addresses in for all "host" values.

After more investigation, I discovered that my distro (Ubuntu 10.04 LTS) had hardcoded my hostname in etc/hosts:

cat /etc/hosts
127.0.0.1	localhost
127.0.1.1	hv01.local	hv01

If I get rid of:

127.0.1.1	hv01.local	hv01

That fixes it and now I am able to use hostnames, unfettered from the confines of static IPs! (unless DNS goes down)

Comment by ramesh37...@gmail.com, Jul 15, 2011

Connected successfully Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 110 in /home/agentvet/public_html/database.php on line 10 Could not connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 110

i have trid to connect to mysql server database in one page. But it is gives error. so please help me how to solve.

Comment by dave@boostpro.com, Aug 6, 2011

A key point worth adding prominently: in the vboxweb config of secondary machines, VBOXWEB_HOST must (at least in my case) be set to the absolute IP address of the secondary machine. localhost doesn't work, and neither does 127.0.0.1.

Comment by ertaner...@gmail.com, Nov 19, 2011

If you use Ubuntu Server pls try this way for manage multiple server,

#/var/www/gui address/config.php

var $username = 'Same to system user name'; var $password = 'Same to system user password';

You can use many server on single screen, not only two.

#/var/www/gui address/config.php

var $servers = array(

array(
'name' => 'VM1-Master', 'username' => 'Same to system user name', 'password' => 'Same to system user password', 'location' => 'http://Real Ethenet IP:18083/',
),
array(
'name' => 'VM2-Master', 'username' => 'Same to system user name', 'password' => 'Same to system user password', 'location' => 'http://Real Ethenet IP:18083/',
), array(
'name' => 'VM3-Master', 'username' => 'Same to system user name', 'password' => 'Same to system user password', 'location' => 'http://Real Ethenet IP:18083/',
),

);

If you want connect to other server with single WebGui? then you must be run your vboxwebsrv

vboxwebsrv -b --host Real Ethenet IP


Sign in to add a comment
Powered by Google Project Hosting