Rabu, 24 Desember 2014

Web VBOX dg phpvbox

Install Oracle VirtualBox And Manage It Using phpVirtualBox On A Ubuntu 14.04 Headless Server

video tutorial;https://www.youtube.com/watch?v=lLIRffJlens
In the previous tutorial, We showed you how to Install Oracle VirtualBox And Manage It Using phpVirtualBox On A CentOS 6.5 Headless Server. Today, we will do the same on Ubuntu 14.04 LTS headless server.
Here is my test box details:
OS : Ubuntu 14.04 LTS Server (No GUI)
IP Address : 192.168.1.250/24

Preparing Ubuntu 14.04 LTS server

Before installing VirtualBox, we have to do a couple of tasks. First of all, update your server.
sudo apt-get update && sudo apt-get upgrade -y
Now, install the following prerequisites which will need by oracle VirtualBox.
sudo apt-get install build-essential dkms unzip -y
Reboot your server once to take effect all the changes.

Installing VirtualBox

Edit /etc/apt/sources.list file:
sudo nano /etc/apt/sources.list
Add the latest oracle virtualbox repository to your Ubuntu server. You can download the oracle virtualbox latest repository from here.
[...]
deb http://download.virtualbox.org/virtualbox/debian trusty contrib
Add the virtualbox public key:
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
Now, update the repository and install latest oracle virtualbox version.
sudo apt-get update
sudo apt-get install VirtualBox-4.3 -y
After installing virtualbox, add the system user sk to the vboxusers group. sk is the system normal user that I have created already. You can create and use a separate new user as your wish. If you use different user, log out and log in back to that user and do the rest of the steps.
sudo usermod -aG vboxusers sk
Now, run the following command to check if virtualbox kernel modules are loaded or not.
sudo /etc/init.d/vboxdrv status
Sample output:
VirtualBox kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) are loaded.
If it, not loaded, run the following command to load them:
sudo /etc/init.d/vboxdrv setup

Install Oracle VirtualBox Extension pack

Starting with VirtualBox 4.0, we should install Extension pack that will help us to manage and connect our remote guest consoles via web interface. This Extension pack provides the following functionalities to the VirtualBox guests.
  • The virtual USB 2.0 (EHCI) device
  • VirtualBox Remote Desktop Protocol (VRDP) support
  • Host webcam passthrough
  • Intel PXE boot ROM
  • Experimental support for PCI passthrough on Linux hosts
VirtualBox extension pack should be same version as VirtualBox base package. Download Extension pack for VirtualBox 4.3 from here.
wget http://download.virtualbox.org/virtualbox/4.3.12/Oracle_VM_VirtualBox_Extension_Pack-4.3.12-93733.vbox-extpack
Then, Install Extension pack as shown below.
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.12-93733.vbox-extpack
That’s it Oracle VirtualBox and Extension pack have been installed successfully on our Ubuntu 14.04 LTS server. Start using Oracle VirtualBox! For creating and managing virtual machines from the command line, refer the official manual.
Instead, you can use Oracle VirtualBox GUI client called “phpvirtualbox”. to easily create and manage virtual machines via web browser of any remote desktop system.

What is phpVirtualBox?

phpVirtualBox is an open source, web-based client written using PHP. It can be used to manage and administer Oracle VirtualBox headless instances.

Install phpVirtualBox

Before installing phpVirtualBox, we have to install Apache web server and PHP. To install Apache, PHP refer the following link.
Additionally, install php-soap extension which is required by phpVirtualBox to work well.
sudo apt-get install php-soap
Restart the web server to take effect the changes.
sudo /etc/init.d/apache2 restart
Now, Download the latest version from the phpVirtualBox official site.
wget http://sourceforge.net/projects/phpvirtualbox/files/phpvirtualbox-4.3-1.zip
Extract the zip file using the following command:
unzip phpvirtualbox-4.3-1.zip
Move the extracted folder to your apache root folder.
sudo mv phpvirtualbox-4.3-1 /var/www/html/phpvirtualbox

Configure phpVirtualBox

Edit phpVirtualBox config.php file:
sudo cp /var/www/html/phpvirtualbox/config.php-example /var/www/html/phpvirtualbox/config.php
sudo nano /var/www/html/phpvirtualbox/config.php
Change the username/password for system user that runs VirtualBox. In our case, the username/password is sk/ubuntu.
[...]
var $username = 'sk';
var $password = 'ubuntu';
[...]
Save and close the file.
Create a file called /etc/default/virtualbox:
sudo nano /etc/default/virtualbox
Append the following line:
VBOXWEB_USER=sk
Now, start vboxweb-service, and make it to start automatically on every reboot.
sudo /etc/init.d/vboxweb-service start

Access phpVirtualBox Web console

Now, go to any client systems that has installed with GUI desktop environements, and try to access the URL http://ip-address-of-virtualbox-headless-server/phpvirtualbox from the web browser.
Now, try again the same URL mentioned above. The following screen should appear. Enter the username/password.
The default username/password is admin/admin.
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_001
Now, you’ll be redirected to the phpVirtualBox main dashboard.
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_002
From here, you can create, modify, delete, and manage virtual machines.

Creating sample Virtual Machine

Let us create a sample virtual machine to install CentOS 6.5 desktop.
Click on the New button on the top left corner. Enter the Virtual machine name.
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_003
Set the Memory size for the virtual machine.
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_004
Select “Create a virtual hard drive now” option.
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_005
Select hard drive file type.
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_006
Choose whether the new virtual hard drive file should grow as it is used (dynamically allocated) or if it should be created at its maximum size (fixed size).
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_007
Enter the size of the virtual hdd.
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_008
That’s it. The virtual machine has been created. Start installing the OS, and use the virtual machine.
phpVirtualBox - VirtualBox Web Console - Mozilla Firefox_009
phpVirtualBox tool will definitely help the system administrators who have only headless Ubuntu 14.04 server, and also the installation is not that difficult. So, You can easily run virtual machines as many as your hardware supports from your headless Ubuntu server.
Cheers!
References:
For questions please refer to our Q/A forum at : http://ask.unixmen.com/

Tidak ada komentar:

Posting Komentar