LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 05-24-2016, 05:25 PM   #1
Steven_G
Member
 
Registered: Dec 2015
Location: Western US
Distribution: Home spun
Posts: 142

Rep: Reputation: 67
How to: Home Vitrualization Lab using Debian 8 Jesse / Virtualbox 4 / phpvirtualbox 4 (complete)


Level: Intermediate

Motivation: Documentation is scattered and incomplete

Assumptions:
1) You understand that this tutorial is *not* for a production server and you understand system security. This machine will have only very minimal security (next to none), no hardening at all and should not be exposed to the world +dog. Its targeted use is enthusiasts such as myself who want to be able to play with a vtlab at home. This machine should at a minimum be behind a router and not in the DMZ. Preferably it should be behind a gateway and a firewall on a LAN with DNS/DHCP servers (even if those are just built in to your router).

2) You understand basic networking and will be able to deploy this machine on your home LAN without assistance.

3) You are already able to install a basic Debian system without assistance; including selecting hardware, the correct installation media, etc.

4) You understand basic headless / remote *nix adminstration like ssh, etc and are comfortable working in the CLI

5) You already know how to use the Virtualbox 4 GUI interface.

6) You have a machine free to dedicate to this specific purpose and understand that this machine most likely will not be suitable for daily use as your “main” computer.

Please note, before going further, after using the environment for a couple of days, IMHO, it is not really suited to virtualizing full desktop type operating systems as the phpvirtualbox 4 web interface can be slow and clunky at times. It has a tendency to freeze and needs to be reinitialized often under a heavy graphical load. It is also clunky to install the Virtualbox guest additions in full DE VMs. It has been my experience that when working in phpvirtualbox 4 that the guestadditions ISO will mount but will not autorun and must be run manually from the CLI. Which, while not difficult, I've noticed that the terminal emulator tends to freeze and lock up in a lot of the GUI / DE environments. However, the phpvirtualbox 4 web interface works *very well* when you are running headless machines in the CLI. I plan to use the environment to emulate things like domain controllers, firewalls, DNS/DHCP servers, mail servers, etc to study for exams and it is well suited to this purpose. On my rig the base install only uses 230 MB of RAM. I have been able to build / run / boot a stripped down mail server good enough for testing / studying purposes using only a 5GB virtual hard drive, 8% of one processor and 256MB RAM. On my rig I will be able to emulate dozens of headless machine at once and will be able to build a scale model of an enterprise class network.

If you choose to follow this tutorial you understand that you are doing so at your own risk.

I will not be providing technical support in this thread. Google is your friend.

So, you have an extra machine around the house and want to whip up a vtlab, but after following several tutorials you keep running in to errors like SOAP exceptions, you can't log in to the interface, the services aren't persistent and won't reinitialize after boot/reboot and it's still just not working as designed; well here's the solution.

This solution is specifically built using Debian 8 jesse, Virtualbox 4 and phpvirtualbox 4. I tried building it with versions 5 of VB and phpvb but could not get it to work. One of the things that I found that is poorly documented is that the entire setup hinges on virtualbox-dkms being installed. The version of virtualbox-dkms currently in the jesse reopos is only compatible with Virtualbox 4. This tutorial *should* work (no guarantees) with versions 5 of vb and phpvb once (or if) debian virtualbox-dkms is updated to be compatible with Virtualbox 5. YMMV.

Conventions:
1) The base OS is admined remotely through SSH / CLI. (You'll need to use wget to DL ISOs. The easiest way I've found is to just copy and paste DL links from the browser on my main terminal.)
2) The VMs are admined through the web interface.
3) I use the 10.10 block for my LAN. If you use the 192.168 block then adjust appropriately.
4) In this install root is locked and sudo is in use and an admin user (user1) is created during install. If you choose to run as root then adjust appropriately. N.B: From what I have read on the web using “root” as user will not work in the php configuration changes that are detailed below.

All version numbers and links are correct as of 5/24/16. You may need to modified them at later dates to be current.

DL / burn to disk or setup on a USB stick a netinstall of debian 8 and do a direct install or do a network deploy if you are set up for that. Define the host name and domain (if you have are on one). Lock root and set up an admin user. Install only the base system utilities and an SSH server. Secure and configure SSH. Add yourself to your own group. (IDK why Debian does not do this automagically.) Create a static IP address in /etc/network/interfaces and deploy the machine to the LAN. (I also installed fail2ban, denyhosts and did some very minimal work in IPTables.)

Many of the commands below will pull in a lot of dependancies; install them all. Note: The recommended installs are not required.

Once the system is deployed to the LAN then SSH in to it from your main terminal.

Make sure the machine is clean and up to date:

Code:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoremove
Get ready to start building out the machine by installing apache, php, some tools, libraries, dependencies and utilities:

Code:
sudo apt-get install apache2 apache2-utils apache2.2-bin apache2-doc apache2-suexec libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libapr1 php5 php5-common php5-mysql php-pear php-soap php5-gd build-essential dkms unzip wget gcc linux-headers-$(uname -r)
Initialize apache by restarting the service:
Code:
sudo systemctl restart apache2.service
To test that the box is serving a web page point your browser from your main computer at it's static IP:
Code:
http://10.10.XXX.XXX
You should get a page stating that this is a default debian apache test page.

Back to the remote SSH console.

Add the Virtualbox repo to your source list:
Code:
sudo nano /etc/apt/sources.list
And add
Code:
#Virtualbox repo
deb http://download.virtualbox.org/virtualbox/debian jessie contrib
Now DL the VB public key
Code:
wget www.virtualbox.org/download/oracle_vbox.asc

sudo apt-key add oracle_vbox.asc
And test:

Code:
sudo apt-get update
(Note: I threw public key errors at this point. I was able to resolve the problem using the info at [SOLVED] Public key)

Install VB, dependencies and tools:
Code:
sudo apt-get install virtualbox-dkms virtualbox-4.3 virtualbox-guest-additions-iso
Configure the vbox web server user (user1)
Code:
sudo nano /etc/default/virtualbox
And add as the last line:
Code:
VBOXWEB_USER=user1
Technically this next step should not be necessary. But I have seen VB not create it's group upon install before so it doesn't hurt to make sure by creating the group manually:
Code:
sudo groupadd vboxusers
Then add yourself to the vboxusers group:
Code:
sudo usermod -a -G vboxusers user1
Now DL the VB extension pack:
Code:
wget http://download.virtualbox.org/virtualbox/4.3.36/Oracle_VM_VirtualBox_Extension_Pack-4.3.36-105129.vbox-extpack
And install it:
Code:
sudo vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.36-105129.vbox-extpack
Now to configure the vbox webserver to act as a daemon so that it will be persistent and survive reboot:
Code:
sudo nano /etc/rc.local
And add before "exit 0" the following line:
Code:
vboxwebsrv -H 127.0.0.1 -b
(This initializes the vbox web server in the background on the local loop back so that it acts as a persistent daemon.)

Now to start / restart / initialize all the services you've already installed so that they are running when phpvirtualbox is installed:
Code:
sudo /etc/init.d/virtualbox start

sudo service vboxdrv start

vboxwebsrv -H 127.0.0.1 -b

sudo /etc/init.d/apache2 restart
Now you DL phpvb:
Code:
wget http://sourceforge.net/projects/phpvirtualbox/files/phpvirtualbox-4.3-3.zip
And unzip it:
Code:
unzip phpvirtualbox-4.3-3.zip
Since this is the only web page you'll be serving move phpvb to the root html directory:
Code:
sudo mv phpvirtualbox-4.3-3 /var/www/html
To make it easier to work with rename it from "phpvirtualbox-4.3-3" to "phpvb":
Code:
sudo mv /var/www/html/phpvirtualbox-4.3-3 /var/www/html/phpvb
And set the example php configuration as the actual configuration:
Code:
sudo mv /var/www/html/phpvb/config.php-example /var/www/html/phpvb/config.php
Now take ownership of the phpvb directory by assigning it to your user1 and their group:
Code:
sudo chown -R user1:user1 /var/www/html/phpvb
Now configure phpvb for your user:
Code:
sudo nano /var/www/html/phpvb/config.php
And edit the user name and password in the following lines:
Code:
[...]
/* Username / Password for system user that runs VirtualBox */
var $username = 'user1';
var $password = 'user1's_password';
[...]
Now shutdown the system to test / ensure that everything is persistent and will initialize from cold boot:
Code:
sudo shutdown -P now
Physically turn the power back on.

From your main computer point your browser at:
Code:
http://10.10.XXX.XXX/phpvb
(Note: if you do not add "/phpvb" after the IP address you will not be able to hit the php vb web interface.)

The default log in is:
user: admin
password: admin

At this point everything should be up running and working and you should have a GUI interface in your web browser that is very close to the original VB4 GUI interface and you should have no problems using it.

---------
Edit:
This set of concise notes is complied from several attempts to build this and running through several break fix scenarios but I never started over from scratch.

If you are having issues getting the vbox services to initialize then try uninstalling virtualbox-dkms and all its deps, installing module-assistant, running "sudo m-a prepare" and reinstalling virtualbox-dkms and all its deps.
----------

References and resources:

Install ‘PhpVirtualBox’ to Manage VirtualBox Virtual Machines via Web Browser in Linux

Easy server virtualization using virtualbox


Setting Up A VirtualBox Server (HowTo)

phpvirtualbox - Running Virtual Machines With VirtualBox 4.2 and phpvirtualbox On A Headless Ubuntu 12.04 Server


/etc/init.d/vboxdrv setup Not Found - VirtualBox Fix!


[SOLVED] Public key


phpVirtualBox A web-based front-end to VirtualBox written in PHP

Virtualbox downloads page

Last edited by Steven_G; 05-24-2016 at 07:50 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Virtualbox and phpvirtualbox problem!!! ehabcisco Linux - Software 8 12-16-2015 08:43 AM
Virtualbox and phpvirtualbox problem !!!! ehabcisco Linux - Virtualization and Cloud 1 12-15-2015 09:30 PM
Virtualbox and phpvirtualbox problem !!!! ehabcisco Linux - Server 1 12-15-2015 08:11 PM
Do I need to complete the Debian guest installation on VM virtualbox the-cod1379 Linux - Virtualization and Cloud 9 09-26-2012 03:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 01:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration