How to install PhpVirtualBox in CentOS - Manage VirtualBox

How to install PhpVirtualBox to Manage VirtualBox From Web browser in Centos 6.x

Virtualbox is a software used for virtualization. Phpvirtualbox allows us to manage the virtualbox guest machines via web browser. So we can configure a virtualbox server with headless support by using phpvirtualbox and then the clients can be able to access the virtualbox over a same network via any type of web browser application in linux.
 

To install Install Virtualbox

Add the repository file to download and install virtualbox on your machine.

[root@linuxhelp ~]# vim /etc/yum.repos.d/virtualbox.repo

Append the following entry into it.

[virtualbox] 
name=Oracle Linux / RHEL / CentOS-$releasever / $basearch - VirtualBox 
baseurl=http://download.virtualbox.org/virtualbox/rpm/el/$releasever/$basearch 
enabled=1 
gpgcheck=1 
gpgkey=http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc

 

Next add and enable the epel repository to install the following package.

[root@linuxhelp ~]# yum install epel-release -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Determining fastest mirrors
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
base                                                                                                                                  | 3.7 kB     00:00     
extras                                                                                                                                | 3.4 kB     00:00     
extras/primary_db                                                                                                                     |  37 kB     00:00     
updates                                                                                                                               | 3.4 kB     00:00     
updates/primary_db                                                                                                                    | 743 kB     00:01     
virtualbox                                                                                                                            |  951 B     00:00     
virtualbox/primary                                                                                                                    | 8.8 kB     00:00     
virtualbox                                                                                                                                             30/30
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed
--> Finished Dependency Resolution.
.
.
.
Transaction Test Succeeded
Running Transaction
  Installing : epel-release-6-8.noarch                                                                                                                   1/1 
  Verifying  : epel-release-6-8.noarch                                                                                                                   1/1 

Installed:
  epel-release.noarch 0:6-8                                                                                                                                  

Complete!

Install the required packages for virutalbox.

[root@linuxhelp ~]# yum install gcc make patch  dkms qt libgomp kernel-headers kernel-devel fontforge binutils glibc-headers glibc-devel -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: mirror01.idc.hinet.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
.
.
.
libs.x86_64 0:1.6.1-8.1.el6    autotrace.x86_64 0:0.31.1-28.el6    cloog-ppl.x86_64 0:0.15.7-1.2.el6         
  cpp.x86_64 0:4.4.7-17.el6             ilmbase.x86_64 0:1.0.1-6.1.el6         libspiro.x86_64 0:20071029-3.1.el6  libuninameslist.x86_64 0:20080409-3.1.el6 
  libwmf.x86_64 0:0.2.8.4-25.el6_7      libwmf-lite.x86_64 0:0.2.8.4-25.el6_7  mpfr.x86_64 0:2.4.1-6.el6           ppl.x86_64 0:0.10.2-11.el6                

Complete!

Configure the environment variable to set the kernel source code for virtualbox. Before that check your kernel version.

[root@linuxhelp ~]# uname -r
2.6.32-642.1.1.el6.x86_64
[root@linuxhelp ~]# export KERN_DIR=/usr/src/kernels/2.6.32-642.1.1.el6.x86_64

Now install virtualbox by using the following command.

[root@linuxhelp ~]#  yum install VirtualBox-5.0 -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: mirror01.idc.hinet.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package VirtualBox-5.0.x86_64 0:5.0.22_108108_el6-1 will be installed
--> Finished Dependency Resolution
.
.
.
No precompiled module for this kernel found -- trying to build one. Messages
emitted during module compilation will be logged to /var/log/vbox-install.log.

Stopping VirtualBox kernel modules [  OK  ]
Uninstalling old VirtualBox DKMS kernel modules [  OK  ]
Trying to register the VirtualBox kernel modules using DKMS [  OK  ]
Starting VirtualBox kernel modules [  OK  ]
  Verifying  : VirtualBox-5.0-5.0.22_108108_el6-1.x86_64                                                                                                 1/1 

Installed:
  VirtualBox-5.0.x86_64 0:5.0.22_108108_el6-1                                                                                                                

Complete!

Run the following command to rebuild virtualbox kernel modules.

[root@linuxhelp ~]# /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel modules                         [  OK  ]
Uninstalling old VirtualBox DKMS kernel modulesError! There are no instances of module: vboxhost
5.0.22 located in the DKMS tree.
                                                           [  OK  ]
Trying to register the VirtualBox kernel modules using DKMS[  OK  ]
Starting VirtualBox kernel modules                         [  OK  ]

Download and install virtualbox extension pack by using following commands.

[root@linuxhelp ~]# wget http://download.virtualbox.org/virtualbox/5.0.0/Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack
--2016-06-22 19:31:30--  http://download.virtualbox.org/virtualbox/5.0.0/Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack
Resolving download.virtualbox.org... 23.211.135.43, 23.211.135.42
Connecting to download.virtualbox.org|23.211.135.43|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18028050 (17M) [text/plain]
Saving to: “Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack”

100%[===================================================================================================================>] 18,028,050   742K/s   in 25s     

2016-06-22 19:31:55 (694 KB/s) - “Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack” saved [18028050/18028050]
[root@linuxhelp ~]# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully installed "Oracle VM VirtualBox Extension Pack".

Create a user account for virtualbox and add the user into vboxusers group.

[root@linuxhelp ~]# useradd linuxhelp
[root@linuxhelp ~]# passwd linuxhelp
Changing password for user linuxhelp.
New password: 
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@linuxhelp ~]# usermod -G vboxusers linuxhelp

To access the virtualbox via web browser we need to install apache web server and php modules as follows,

[root@linuxhelp ~]# yum install httpd php php-devel php-gd php-common php-soap -y
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: mirror01.idc.hinet.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Package httpd-2.2.15-53.el6.centos.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.3-47.el6 will be installed
.
.
.
Dependency Installed:
  autoconf.noarch 0:2.63-5.1.el6         automake.noarch 0:1.11.1-4.el6         libXpm.x86_64 0:3.5.10-2.el6         php-cli.x86_64 0:5.3.3-47.el6        

Complete!

 

To install phpVirtualBox

Run the following command to download phpvirtualbox.

[root@linuxhelp ~]# wget http://heanet.dl.sourceforge.net/project/phpvirtualbox/phpvirtualbox-5.0-5.zip
--2016-06-22 19:33:54--  http://heanet.dl.sourceforge.net/project/phpvirtualbox/phpvirtualbox-5.0-5.zip
Resolving heanet.dl.sourceforge.net... 193.1.193.66, 2001:770:18:aa40::c101:c142
Connecting to heanet.dl.sourceforge.net|193.1.193.66|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4093766 (3.9M) [application/octet-stream]
Saving to: “phpvirtualbox-5.0-5.zip”

100%[===================================================================================================================>] 4,093,766    529K/s   in 8.6s    

2016-06-22 19:34:03 (466 KB/s) - “phpvirtualbox-5.0-5.zip” saved [4093766/4093766]

[root@linuxhelp ~]# ls
anaconda-ks.cfg  Documents  install.log         Music                                                          phpvirtualbox-5.0-5.zip  Public     Videos
Desktop          Downloads  install.log.syslog  Oracle_VM_VirtualBox_Extension_Pack-5.0.0-101573.vbox-extpack  Pictures                 Templates

unzip the downloaded package by using the following command.

[root@linuxhelp ~]# unzip phpvirtualbox-5.0-5.zip 
Archive:  phpvirtualbox-5.0-5.zip
   creating: phpvirtualbox-5.0-5/
  inflating: phpvirtualbox-5.0-5/.dockerignore  
  inflating: phpvirtualbox-5.0-5/.gitignore  
  inflating: phpvirtualbox-5.0-5/CHANGELOG.txt  
  inflating: phpvirtualbox-5.0-5/config.php-example  
   creating: phpvirtualbox-5.0-5/css/
  inflating: phpvirtualbox-5.0-5/css/jquery-ui.css
.
.
.
  inflating: phpvirtualbox-5.0-5/rdpweb/swfobject.js  
  inflating: phpvirtualbox-5.0-5/rdpweb/webclient.js  
  inflating: phpvirtualbox-5.0-5/rdpweb/webclient3.html  
  inflating: phpvirtualbox-5.0-5/README.md  
  inflating: phpvirtualbox-5.0-5/recovery.php-disabled  
   creating: phpvirtualbox-5.0-5/tightvnc/
  inflating: phpvirtualbox-5.0-5/tightvnc/VncViewer.jar  
  inflating: phpvirtualbox-5.0-5/vboxinit

Execute the following command to move the extracted phpvirtualbox directory into the default document root of apache web server.

[root@linuxhelp ~]# mv phpvirtualbox-5.0-5 /var/www/html/phpvirtualbox

Copy the content of the config.php file located under /var/www/html/phpvirtualbox and then edit the file as follows,

[root@linuxhelp ~]# cp /var/www/html/phpvirtualbox/config.php-example /var/www/html/phpvirtualbox/config.php
[root@linuxhelp ~]# vim /var/www/html/phpvirtualbox/config.php

Add the username and password for the virtualbox user.

var $username = 'linuxhelp';
var $password = '123';

Now create a new file virtualbox in the location /etc/default/  and add the below mentioned entry for virtualbox user.

[root@linuxhelp ~]# vim /etc/default/virtualbox

 

VBOXWEB_USER=linuxhelp

Run the following command to start virtualbox web service and apache service.

[root@linuxhelp ~]# /etc/init.d/vboxweb-service start
Starting VirtualBox web service                            [  OK  ]
[root@linuxhelp ~]# service httpd start
Starting httpd:                                            [  OK  ]

Now enable the apache service to start automatically for next boot up.

[root@linuxhelp ~]# chkconfig httpd on

 

To Disable the selinux

[root@linuxhelp ~]# vim /etc/sysconfig/selinux

And change SELINUX to disabled.

SELINUX=disabled

Restart your system and open your browser to connect to virtualbox.

 you need to enable the firewall for apache service to allow the access for your clients.


Open the browser and type http://<IP_address>/phpvirtualbox

welcome page
Now login with user credentials.
login page

php virtualbox

Now you can access the phpvirtualbox over a network.


Thank you! for using Linux Help.

You find this tutorial helpful? Share with your friends to keep it alive.
For more help topics browse our website www.linuxhelp.com
Be the first to comment, we value your suggestions. For further queries please comment below.

Tags: Php Virtualbox
user image Author :  Elijah