how to install VirtualBox 4.2 and phpVirtualBox


With this tutorial we are going to explain how to install VirtualBox 4.2 and phpVirtualBox for remote management on Debian Linux.

Installing VirtualBox 4.2

We need to add the Debian repository for add the public key and install VirtualBox 4.2

vi /etc/apt/sources.list
deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
apt-get update
apt-get install virtualbox-4.2

For different versions of Debian you can use the following repositories

deb http://download.virtualbox.org/virtualbox/debian precise contrib
deb http://download.virtualbox.org/virtualbox/debian oneiric contrib
deb http://download.virtualbox.org/virtualbox/debian natty contrib
deb http://download.virtualbox.org/virtualbox/debian maverick contrib non-free
deb http://download.virtualbox.org/virtualbox/debian lucid contrib non-free
deb http://download.virtualbox.org/virtualbox/debian karmic contrib non-free
deb http://download.virtualbox.org/virtualbox/debian hardy contrib non-free
deb http://download.virtualbox.org/virtualbox/debian wheezy contrib
deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free
deb http://download.virtualbox.org/virtualbox/debian lenny contrib non-free

Now we need to install VirtualBox Extension Pack

cd /tmp
wget http://download.virtualbox.org/virtualbox/4.2.0/Oracle_VM_VirtualBox_Extension_Pack-4.2.0-80737.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.0-80737.vbox-extpack
We need to create vbox user for VirtualBox and phpVirtualBox and add it to vboxusers group

useradd -d /home/vbox -m -g vboxusers -s /bin/bash vbox
passwd vbox
Create the file /etc/default/virtualbox and put the following lines so that the VirtualBox SOAP API which is called vboxwebsrv runs as the user vbox

vi /etc/default/virtualbox
VBOXWEB_USER=vbox
Next we need to set vboxweb-service to start on boot

update-rc.d vboxweb-service defaults
/etc/init.d/vboxweb-service start
Installing phpVirtualBox

We are going to install nginx and PHP to support phpVirtualBox

apt-get install nginx php5-common php5-mysql php5-suhosin php5-fpm php-pear unzip
/etc/init.d/nginx start
Make changes to nginx default site so you can access your phpVirtualBox website

vi /etc/nginx/sites-available/default
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6

root /usr/share/nginx/www;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}

location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}

# Only for nginx-naxsi : process denied requests
#location /RequestDenied {
# For example, return an error code
#return 418;
#}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ /\.ht {
deny all;
}
}
/etc/init.d/nginx reload
Now we are going to install phpVirtualBox

cd /usr/share/nginx/www
wget http://phpvirtualbox.googlecode.com/files/phpvirtualbox-4.2-0b.zip
unzip phpvirtualbox-4.2-0b.zip
mv phpvirtualbox-4.2-0b phpvirtualbox
Copy the config file and set the user and password for your vbox user

cd /usr/share/nginx/www/phpvirtualbox/
cp config.php-example config.php
vi config.php
/* Username / Password for system user that runs VirtualBox */
var $username = ‘vbox’;
var $password = ‘yourpassword’;
That’s it. Open your browser and login using the default username and password which is admin

VirtualBox: https://www.virtualbox.org/
phpVirtualBox: http://code.google.com/p/phpvirtualbox/

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s