Run Virtual Machines with VirtualBox and Manage VirtualBox Installations with phpvirtualbox

Valic —  October 3, 2012 — 2 Comments

In this tutorial I will show you how you can run virtual machines with VirtualBox  on a Debian Squeeze server and how to manage your virtual machines with phpvirtualbox.
Phpvirtualbox is a web based VirtualBox front-end written in PHP that allows you to access and control remote VirtualBox machines.

Step1. First we need to create an user called Administrator and group with the same name.

root@css:~# groupadd administrator
root@css:~# useradd -d /home/administrator -m -g administrator -s /bin/bash administrator
root@css:~# passwd administrator
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Step2. Install VirtualBox
Add the VirtualBox repository in your sources.list file and download the VirtualBox public key:

echo “deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free” >> /etc/apt/sources.list
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -

Now install VirtualBox using the following command:

apt-get update && apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.0 dkms

Step3. Install so called “extension packs“. Starting with version 4.0, VirtualBox has introduced extension packs.
This “pack” it’s used for remote desktop connection support.

Now go to http://www.virtualbox.org/wiki/Downloads and download the following:

wget http://download.virtualbox.org/virtualbox/4.0.16/Oracle_VM_VirtualBox_Extension_Pack-4.0.16-75491.vbox-extpack

Install the pachage using the command:

# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.0.16-75491.vbox-extpack
0%…10%…20%…30%…40%…50%…60%…70%…80%…90%…100%
Successfully installed “Oracle VM VirtualBox Extension Pack”

Step4. You need to add the user administrator that you just created earlier to vboxusers group.

# adduser administrator vboxusers
Adding user `administrator’ to group `vboxusers’ …
Adding user administrator to group vboxusers
Done.

Part two: Install and use phpvirtualbox.

Step1. First we need to create a user called vbox and add it to the vboxusers group:

# useradd -m vbox -G vboxusers
root@css:/usr/src/vb# passwd vbox
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Step2. Create the file /etc/default/virtualbox and put the following line in it:

echo “VBOXWEB_USER=vbox” > /etc/default/virtualbox

Step3. Now we need to set the vboxwebsrv service to run on system startup:

# update-rc.d vboxweb-service defaults
update-rc.d: using dependency based boot sequencing
root@css:# /etc/init.d/vboxweb-service start
Starting VirtualBox web service:done..
root@css:# /etc/init.d/vboxweb-service status
Checking for VBox Web Service …running

Step4. Download and install phpvirtualbox:

Download phpvirtualbox from here: https://code.google.com/p/phpvirtualbox/
To programmatically determine and download the latest version. Use:

wget `wget -q -O – http://phpvirtualbox.googlecode.com/files/LATEST.txt` -O phpvirtualbox-latest.zip

Step5. Assuming that a Apache webserver is already installed on server, e.g. as described in the tutorial How to Install Apache2.4 PHP5 and MySQL from Source on Debian Linux , unzip phpvirtualbox archive in /var/www folder and rename the phpvirtualbox-4.2-0b to phpvirtualbox.

unzip phpvirtualbox-4.2-0b.zip
mv phpvirtualbox-4.2-0b phpvirtualbox
mv phpvirtualbox /var/www/

Step6. Now go to the /var/www/phpvirtualbox/ directory and edit the config.php-example with your xbox user password.
Then rename it to config.php.

nano config.php-example

/* Username / Password for system user that runs VirtualBox */
var $username = ‘vbox’;
var $password = ‘your_password’;

mv config.php-example config

Step7. You can now access phpvirtualbox from your browser:

http://localhost/phpvirtualbox/

When will ask for user and password use the default user and password. (admin/admin)

To change change the admin password go to File > Change Password.

Step8. Now you can create virtual machines in the same way that you create on your computer.

Enjoy.

Valic

Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

Trackbacks and Pingbacks:

  1. Debian copy/paste Tutorials - Linux Tutorials - VirtualBox Commands List - February 14, 2013

    [...] you installed VirtualBox following this guide Run Virtual Machines and you are new to VirtualBox, then the following commands will help you to gather information and [...]

  2. test | Debian Tutorials - February 17, 2013

    [...] you installed VirtualBox following this guide Run Virtual Machines and you are new to VirtualBox, then the following commands will help you to gather information and [...]

Leave a Reply