Brian Padgett's picture

Hi everyone,

I have been enjoying the fruits of this forumn and the Turnkey virtual appliances for a couple of years now. I figured it was hi time I give back a little. It's not very much but I hope it will help someone looking to setup their own headless virtualbox host. 

Maybe it would be possible to get this in the Virtual appliance lineup at some point.

Here we go...

VirtualBox 4.2 and phpVirtualBox on Turnkey Lamp 12.1 Debian Squeeze

Installing VirtualBox 4.2 

 

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

nano /etc/apt/sources.list

deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free

 

Run the following commands:

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.18/Oracle_VM_VirtualBox_Ex...

VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.18-88780.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

 

Using Dotdeb for PHP5 repository to update PHP.

 

1. Add the main repository to your sources.listAdd these two lines to your /etc/apt/sources.list file

deb http://packages.dotdeb.org squeeze all

deb-src http://packages.dotdeb.org squeeze all

2. Fetch and install the GnuPG key

wget http://www.dotdeb.org/dotdeb.gpg

cat dotdeb.gpg | sudo apt-key add -

3. Update

apt-get update

Installing phpVirtualBox 

We are going to install or update the following to support phpVirtualBox

apt-get install php5-common php5-mysql php5-suhosin php5-fpm php-pear

 

Now we are going to install phpVirtualBox

cd /var/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 /var/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';

 

Now open your browser and point it to:

http://your_server_ip/phpvirtualbox

To login, you will need to use admin for the user and admin for the password. Don't ask me why. 
I have not resolved that issue yet. Once you login, you should obviously change your password 
from the menu bar FILE> CHANGE PASSWORD.

 

That's it! Enjoy!

 

I also edited my index.php file to add PHPVirtualBox to the default Turnkey Control Panel.

Here's the code for that.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

 

<html lang="en">

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

        <meta http-equiv="Content-Style-Type" content="text/css">

        <meta http-equiv="Content-Script-Type" content="text/javascript">

 

        <title>TurnKey PHPVirtualBox</title>

       

        <link rel="stylesheet" href="css/ui.tabs.css" type="text/css" media="print, projection, screen"/>

        <link rel="stylesheet" href="css/base.css" type="text/css"/>

 

        <script src="js/jquery-1.2.6.js" type="text/javascript"></script>

        <script src="js/ui.core.js" type="text/javascript"></script>

        <script src="js/ui.tabs.js" type="text/javascript"></script>

        <script type="text/javascript">

            $(function() {

                $('#container-1 > ul').tabs({ fx: { opacity: 'toggle'} });

            });

        </script>

    </head>

 

    <body>

        <h1>TurnKey PHPVirtualBox</h1>

       

        <div id="container-1">

            <ul>

                <li><a href="#cp"><span>Control Panel</span></a></li>

            </ul>

 

            <div id="cp">

                <div class="fragment-content">

                    <div>

                        <a href="https://<?php print

                        $_SERVER{'HTTP_HOST'}; ?>:12320"><img

                        src="images/shell.png"/>Web Shell</a>

                    </div>

                    <div>

                        <a href="https://<?php print

                        $_SERVER{'HTTP_HOST'}; ?>:12321"><img

                        src="images/webmin.png"/>Webmin</a>

                    </div>

                    <div>

                        <a href="https://<?php print

                        $_SERVER{'HTTP_HOST'}; ?>:12322"><img

                        src="images/phpmyadmin.png"/>PHPMyAdmin</a>

                    </div>

                     <div>

                        <a href="https://<?php print

                        $_SERVER{'HTTP_HOST'}; ?>/phpvirtualbox"><img

                        src="images/shell.png"/>PHPVirtualBox</a>

                    </div>

 

                    <div></div>

                    <div></div>

 

                    <h2>Resources and references</h2>

                    <ul>

 

                        <li>

                          <a href="/phpinfo.php">Apache PHP information</a>

                          (to disable: rm /var/www/phpinfo.php)

                        </li>

                        <li>

                          <a href="/server-status">Apache server status</a>

                          (to disable: a2dismod status)

                        </li>

                        <li><a

                        href="http://www.turnkeylinux.org/lamp">

                        TurnKey LAMP release notes</a></li>

                    </ul>

 

                </div>

            </div>

 

        </div>

    </body>

</html>

Attached: 
Forum: 
Brian Padgett's picture

I have been using my new headless virtualbox server for about 24hrs now. I am blown away by the difference in performance over running virtualbox on Windows7 host with exact same hardware. The system is an Intel i5 32Gb DDR3.

Before I would have to run my Turnkey Wordpress VM with up to 3Gb ram to get good performance from the Wordpress site. I could only host about five VMs. If I hosted a sixth VM the Windows7 64bit host would blue screen.

I ran tests for months and could not find a hardware or driver problem. I am convinced it is a bug in Windows7. I have duplicated the blue screen on two other Windows7 systems. I can now run each Turnkey Wordpress VM with only 512Mb and could probrably go less than that and it runs lightning fast. 

Just wanted to share incase anyone else runs into the same issues!

A shout out to the devs. Thanks for all the hard work you guys put in! I am trying to learn how to develop with the TKL Virtual Environment so I can give back a little. A headless virtualbox vm will probrably be my first project.

Jeremy Davis's picture

Personally I prefer ProxmoxVE as OVZ containers use even less resources.... But my preferences aside your contribution is warmly welcome. I know that Rik worked on this some time ago and spoke highly of it...

If you want to push development of this forward and even perhaps have it included in the v13.0 lineup then perhaps have a look at the development page and consider building a v13 (Debian Wheezy) based version with TKLDev.

Regardless, great work :)

Ryan's picture

Not sure your vbox user should have shell access?

 

useradd -d /home/vbox -m -g vboxusers -s /bin/false vbox


This recipe is far too stale... had all kinds of breakage with the dotdeb packages - conflicts and dependancies that could not be resolved with recent turnkey/wheezy

 

Would like to see a current recipe as all the phpvirtualbox guides seem to be woefully out of date.

 

K

 

 

Jeremy Davis's picture

Just having a quick glance over it here's my 2c: It looks to me like the dotdeb bits can be eliminated (just install from repos). I'm not sure about v13.0/Wheezy but php (and php-module) version(s) in (new) v14.0/Jessie should be fine for this to work OOTB. Also php5-suhosin hasn't been in Debian for quite some time. Apparently the important bits of it have been merged into the php5 package so I'd just leave that out. If you get to a point if/where you find you do need it then try install from upstream.

TBH I'd still really like to see this appliance make it into the library... It will probably require users to install the last bit themselves (the VBox "extension pack") because of licensing but otherwise shouldn't be a reason why we couldn't do this... Let us know how you go with it...

Add new comment