📜 ⬆️ ⬇️

Virtualization with Ubuntu Server 16.04 and pHpVirtualBox 5.0.5

Recently I was faced with the task of quickly and easily deploying servers based on a bundle of Ubuntu Server 16.04 and pHpVirtualBox 5.0.5 for further virtualization of every OS.
The task is trivial, but quick, simple, and most importantly - I did not find a step-by-step recipe, so I decided to post a primitive FAQ for all those interested in the results of a successful installation.

And so, first install the system - in my case it is Ubuntu Server 16.04 LTS 64-bit. I will not describe the process, everything is standard here.

Next, do not forget to update our system:

sudo apt update sudo apt upgrade 

We are waiting for the completion and restart:
')
 sudo shutdown -R now 

The next step after the reboot is to add the repository and key:

 sudo echo 'deb http://download.virtualbox.org/virtualbox/debian precise contrib' >> /etc/apt/sources.list wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add - 

After this, install VirtualBox itself and additional modules:

 sudo apt-get install virtualbox sudo apt-get install dkms sudo apt-get install libcurl3 

After waiting for the installation to finish, check the version of VirtualBox installed with the command:

 vboxwebsrv -V 

Based on the version information received, go to http://download.virtualbox.org/virtualbox and download the appropriate version of the Extension Pack. In my case, this is version 5.0.24-108355:

 wget http://download.virtualbox.org/virtualbox/5.0.24/Oracle_VM_VirtualBox_Extension_Pack-5.0.24-108355a.vbox-extpack 

When the download is complete, you need to install it:

 sudo vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.0.24-108355a.vbox-extpack 

We wait for the installation and restart the service:

 sudo /etc/init.d/virtualbox stop sudo /etc/init.d/virtualbox start 

After that, you can create and add a user to the group from which our VirtualBox will start:

 sudo adduser vbox sudo usermod -a -G vboxusers 'vbox' 

Now install Apache2 and PHP:

 sudo apt-get install apache2 sudo apt-get install php sudo apt-get install -y php7.0-mbstring php7.0-zip php7.0-xml 

Do not forget to allow the rights to the folder:

 sudo chown -R www-data:www-data /var/www 

And a little more shamanism:

 sudo service apache2 restart sudo a2enconf php7.0-fpm sudo service apache2 reload sudo apt-get install php-soap sudo service apache2 reload 

If there is no archiver on the machine, you need to correct this annoying circumstance:

 sudo apt-get install unzip unrar 

We wait until the end of the process, and proceed to downloading phpVirtualBox:

 wget http://sourceforge.net/projects/phpvirtualbox/files/phpvirtualbox-5.0-5.zip 

A passing remark - if Midnight Commander is not installed, I recommend installing and running (adherents of the old school may laugh condescendingly, but it's more convenient for me):

 sudo apt-get install mc sudo mc 

Now being in the cozy and familiar interface mc, unzip the contents of phpvirtualbox-5.0-5.zip in / var / www / html after cleaning the folder / html .

Next, find the config.php-example file in the / html folder and make config.php out of it.
After we edit the following parameters in it:

 var $username = 'user';  ,   vbox var $password = 'password';   var $location = 'http://192.168.0.1:18083/';    - var $vrdeports = '9000-9100';  var $consoleHost = '192.168.0.1';       VirtualBox 

And the line var servers = array - comment out.

Save the changes, exit mc and some more magic for user groups:

 sudo chgrp vboxusers /etc/vbox sudo chmod 1775 /etc/vbox 

Almost done, it remains to teach VirtualBox independence, and specifically - automatically raise the service.

To do this, go to the / etc / vbox folder and create an autostart.cfg file within which we write:

 default_policy = deny vbox = { allow = true startup_delay = 10 } 

Save, then create the files vbox.start and vbox.stop .

Inside each file, write the value 1 and do not forget to save.

The next step is to open the file using the / etc / default / virtualbox editor:

 VBOXWEB_USER=vbox VBOXWEB_HOST=192.168.0.1 VBOXWEB_PORT=18083 VBOXAOTPSTART_DB=/etc/vbox VBOXAOTPSTART_CONFIG=/etc/vbox/autostart.cfg 

We save, go further to the /etc/rc.local file and append the line:

 sudo -u vbox vboxwebsrv --host 192.168.0.1 

This will give our service independence with further system reboots. Save and reboot with the command:

 sudo shutdown -R now 

After rebooting the system, we open the browser on the remote machine and go to 192.168.0.1, where we are met by an attractive graphical interface.

Default Access:

login - admin
password - admin

There may be problems with restricting access due to JAVA. What would be allowed, we write exceptions in JAVA policy:

 permission java.net.SocketPermission "192.168.0.1:1024-65535","connect,accept,resolve"; permission java.net.SocketPermission "192.168.0.1:1-1023","connect,resolve"; 

After creating the virtual machines, you can make them autostart with an unplanned reboot. To do this, I simply add in the /etc/rc.local file:

 sudo -H -u vbox vboxmanage startvm __ --type headless 

Good luck to all!

Source: https://habr.com/ru/post/319286/


All Articles