Hypervisor for Dummies

Hello! I decided to share the experience of creating a hypervisor based on Ubuntu server 14.04 LTS and a free virtual machine virtualbox 5.2 with a web-based management interface for both the server itself (webmin) and virtual machines (phpvirtualbox). On the network, you can find crooked instructions on raising the above on ubuntu server 16.04, but this instruction is obsolete and offers the version of virtualbox 5.0-5, despite the fact that at 16.04 in version 5.2, the official repositories took root. Here we fix it all. This instruction applies to both ubuntu server 14.04 and 16.04. On more recent versions I did not check, but I suspect that it will also work. So, let's begin.

1. To begin, after installing ubuntu, you should update all the packages and the kernel:

sudo apt-get -y update && sudo apt-get -y dist-upgrade

2. Then reboot:

sudo reboot now

3. Now we will recreate sources.list with the addition of necessary repositories (for 14.04, if you have a higher version, you will have to edit trusty handles on your code name (except webmin, it is always sarge)). For convenience, log in as root:

su
or
sudo -i

4. Then backup sources.list and create a clean one:

cd /root
mv /etc/apt/sources.list /etc/apt/sources.list.bak
touch /etc/apt/sources.list
nano /etc/apt/sources.list

5. Paste this into the new sources.list file:

# 
deb http://ru.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://ru.archive.ubuntu.com/ubuntu/ trusty main restricted
deb http://ru.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://ru.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb http://ru.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://ru.archive.ubuntu.com/ubuntu/ trusty universe
deb http://ru.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://ru.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb http://ru.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://ru.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://ru.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://ru.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb http://ru.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://ru.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner
## deb http://extras.ubuntu.com/ubuntu trusty main
## deb-src http://extras.ubuntu.com/ubuntu trusty main
deb https://download.webmin.com/download/repository sarge contrib
deb http://download.virtualbox.org/virtualbox/debian trusty contrib

6. Download and install the keys:

wget http://www.webmin.com/jcameron-key.asc
wget https://www.virtualbox.org/download/oracle_vbox_2016.asc
wget https://www.virtualbox.org/download/oracle_vbox.asc
apt-key add jcameron-key.asc
apt-key add oracle_vbox.asc
apt-key add oracle_vbox_2016.asc
apt-get update

7. Install the necessary packages:

apt-get install mysql-server apache2 php-soap webmin mc unzip traceroute
apt-get install virtualbox-5.2

8. Add a user:

usermod -aG vboxusers {имя пользователя}

Important! Use the name of the user present in the system, because it is from him that the virtual machines will be launched.
9. Next, download and install the Extension Pack:

wget https://download.virtualbox.org/virtualbox/5.2.26/Oracle_VM_VirtualBox_Extension_Pack-5.2.26.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.26.vbox-extpack

10. It remains the case for webmord, download and install:

wget https://github.com/phpvirtualbox/phpvirtualbox/archive/5.2-1.zip
mv phpvirtualbox-5.2-1 /var/www/html/phpvirtualbox

11. Assign the owner and rights:

chown -R www-data:www-data /var/www/html/phpvirtualbox
chmod -R 755 /var/www/html/phpvirtualbox

12. Now copy and edit the config:

cp /var/www/html/phpvirtualbox/config.php-example /var/www/html/phpvirtualbox/config.php
nano /var/www/html/phpvirtualbox/config.php

13. In the opened config we are only interested in 2 lines, namely

var $username = 'user';
var $password = 'password';

here we enter the real username and password from the account specified in clause 8.

14. Create and edit the / etc / default / virtualbox file:

nano /etc/default/virtualbox
and add there
VBOXWEB_USER={имя пользователя из пункта 8}

15. Reboot:

reboot now


16. On guest OS, you need to install Guest additions, download the image and mount it in the virtual machine's drive:
wget https://download.virtualbox.org/virtualbox/5.2.26/VBoxGuestAdditions_5.2.26.iso 

For * nix machines, install the necessary packages:
sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)

Mount the drive:
sudo mount /dev/sr0/ /media/cdrom
and we start from the superuser
cd /media/cdrom
./VBoxLinuxAdditions.run

For machines on Windows, we simply run Autorun or Setup.exe.

If everything went well, then after rebooting, the http://{ip адрес сервера}/phpvirtualboxvirtual machine management interface will be available at the address , and https://{ip адрес сервера}:10000webmin will be available at the address - a powerful server management interface. To log in to the virtual machine management interface, use the standard username and password admin: admin (changes in the interface itself), and for authorization in webmin, use the real user account with root privileges (you can directly root if you unblocked it).

Also popular now: