VirtualBox 4.3 and phpVirtualBox on Debian wheezy

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

As in my previous post VirtualBox 4.2 and phpVirtualBox on Debian this installation is done on a fresh Debian 7.2.0 server. Some of the parts are changed so this installation can work with simple copy/paste.

Installing VirtualBox 4.3

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

vi /etc/apt/sources.list.d/virtualbox.list
deb http://download.virtualbox.org/virtualbox/debian wheezy contrib

Run the following commands to add the VirtualBox public key for the VirtualBox apt source:

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
apt-get update
apt-get install virtualbox-4.3

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, you can find the latest version here: https://www.virtualbox.org/wiki/Downloads

cd /tmp
wget http://download.virtualbox.org/virtualbox/4.3.2/Oracle_VM_VirtualBox_Extension_Pack-4.3.2-90405.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.2-90405.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 for VirtualBox 4.3

We are going to install nginx and PHP to support phpVirtualBox

apt-get install nginx php5-common php5-mysql 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 unix:/var/run/php5-fpm.sock;
                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://downloads.sourceforge.net/project/phpvirtualbox/phpvirtualbox-4.3-0.zip
unzip phpvirtualbox-4.3-0.zip

Copy the config file and set the user and password for your vbox user

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 4.3.2 phpVirtualBox

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