Install Debian 10.x – Openmediavault 5.X – Virtualbox 6.X - PHPVirtualbox
This is walktrough for installing OMV5 in combination with Virtualbox 6. When using OMV-Extras you have the possibility to use Cockpit for your Virtual Machines.
After working with Virtualbox for the last 5 years I find that Cocpit lacks the features that Virtualbox has.
I'm fairly new to Linux so use this at own risk. I find that everything is just running fine!
I did the installation as root, so i didn't ran into any permission problems.
Install debian 10.1 including SSH
Network config: (set static ip in interfaces - This is later adopted by OMV)
nano /etc/network/interfaces
----------example-------------
iface enp0s17 inet static
address 192.168.X.X
netmask 255.255.255.0
gateway 192.168.X.X
dns-nameservers 192.168.X.X
----------example-------------
"[CTRL] X Y [Enter]" - Save the file.
SSH permit root login
nano /etc/ssh/sshd_config
PermitRootLogin yes
"[CTRL] X Y [Enter]" - Save the file.
Install OMV5.X
apt-get install build-essential
nano /etc/apt/sources.list.d/openmediavault.list
deb https://packages.openmediavault.org/public usul main
"[CTRL] X Y [Enter]" - Save the file.
export LANG=C
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
wget -O "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc" https://packages.openmediavault.org/public/archive.key
apt-key add "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc"
apt update
apt install postfix openmediavault
omv-confdbadm populate
Login to Openmediavault (admin - openmediavault)
Enable all networkcards in OMV5 (if more than one)
Mount all your disks in OMV5
Install Virtualbox 6.x
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian buster contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update
sudo apt install linux-headers-$(uname -r) dkms
sudo apt install virtualbox-6.1
Install Virtualbox extension pack
cd ~/
wget https://download.virtualbox.org/virtualbox/6.1.0/Oracle_VM_VirtualBox_Extension_Pack-6.1.0.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.0.vbox-extpack
Create user "vbox" and make this user a member of "vboxusers"
adduser vbox
sudo usermod -aG vboxusers vbox
sudo systemctl status vboxdrv
(see if vboxservices are running - should be "active (exited)")
Install phpvirtualbox
sudo apt-get install php7.3-soap
(next on a client PC/Laptop)
download: https://github.com/phpvirtualb…albox/archive/develop.zip
Extract and rename folder to: "phpvirtualbox"
open config.php-example in folder "phpvirtualbox" with notepad(++)
var $username = 'vbox';
var $password = 'vbox'; (or the password supplied by you)
var $enableAdvancedConfig = true;
save file as config.php
copy folder "phpvirtualbox" to /var/www
On the OMV machine:
chown -R 998:996 /var/www/phpvirtualbox
chmod -R 755 /var/www/phpvirtualbox/
sudo nano /etc/default/virtualbox
VBOXWEB_USER=vbox
"[CTRL] X Y [Enter]" - Save the file.
Restart vbox services
sudo systemctl restart vboxdrv
sudo systemctl restart vboxweb-service
Create user "phpvirtualbox-webgui" for NGINX
adduser phpvirtualbox-webgui
(password: phpvirtualbox)
Create configfifle for website "phpvirtualbox-webgui" that runs in NGINX
nano /etc/nginx/sites-available/phpvirtualbox-webgui
server {
server_name phpvirtualbox-webgui;
root /var/www/phpvirtualbox;
index index.html;
autoindex off;
server_tokens off;
sendfile on;
large_client_header_buffers 4 32k;
client_max_body_size 25M;
error_log /var/log/nginx/phpvirtualbox-webgui_error.log error;
access_log /var/log/nginx/phpvirtualbox-webgui_access.log combined;
error_page 404 = /404.php;
location /404.html {
internal;
}
location /extjs6/ {
alias /usr/share/javascript/extjs6/;
expires 2d;
}
location ~ ^/(css|js|images)/ {
expires 2d;
}
location /favicon {
expires 14d;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.3-fpm-phpvirtualbox-webgui.sock;
fastcgi_index index.php;
fastcgi_read_timeout 60s;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
listen [::]:8080 ipv6only=off;
include /etc/nginx/phpvirtualbox-webgui.d/*.conf;
}
Display More
"[CTRL] X Y [Enter]" - Save the file.
Create configuration file for "php-fpm"
nano /etc/php/7.3/fpm/pool.d/phpvirtualbox-webgui.conf
[phpvirtualbox-webgui]
user = phpvirtualbox-webgui
group = phpvirtualbox-webgui
listen = /run/php/php7.3-fpm-phpvirtualbox-webgui.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0600
pm = ondemand
pm.max_children = 25
pm.process_idle_timeout = 10s
chdir = /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; phpvirtualbox php.ini settings ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories
php_value[include_path] = ".:/usr/share/php:/var/www/phpvirtualbox"
; Pam Authentication Support (see /etc/pam.d)
php_value[pam.servicename] = "phpvirtualbox-webgui";
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
php_value[upload_max_filesize] = 25M
; Maximum size of POST data that PHP will accept.
; http://php.net/post-max-size
php_value[post_max_size] = 25M
; Do not expose to the world that PHP is installed on the server.
; http://php.net/expose-php
php_value[expose_php] = Off
; Name of the session (used as cookie name).
; http://php.net/session.name
php_value[session.name] = X-PHPVIRTUALBOX-SESSIONID
; Default timeout for socket based streams (seconds)
; http://php.net/default-socket-timeout
php_value[default_socket_timeout] = 90
; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
php_value[max_execution_time] = 90
Display More
"[CTRL] X Y [Enter]" - Save the file.
Activate PHPVirtualbox website
sudo ln -s /etc/nginx/sites-available/phpvirtualbox-webgui /etc/nginx/sites-enabled/
systemctl restart nginx
systemctl restart php7.3-fpm
Check if you can reach phpvirtualbox by entering the following URL: "http://[your-OMV5-server]:8080/" in for instance "Firefox"
The default username and password for phpvirtualbox is admin/admin
Start and Stop VM’s automaticly on boot and shutdown
nano /etc/default/virtualbox
"[CTRL] X Y [Enter]" - Save the file.
nano /etc/vbox/autostart.cfg
default_policy = deny
# Create an entry for each user allowed to use autostart
vbox = {
allow = true
}
"[CTRL] X Y [Enter]" - Save the file.
sudo chgrp vboxusers /etc/vbox
sudo chmod 1775 /etc/vbox
Choose VMs to automatically start and stop
The first time a user configures autostart, the command: VBoxManage setproperty autostartdbpath /etc/vbox needs to be run.
Note: The autostart options are stored in the /etc/vbox file, and the VM itself. If moving the vm, the options may need to be set again.
VBoxManage modifyvm <uuid|vmname> --autostart-enabled <on|off>
You can also: VBoxManage modifyvm <uuid|vmname> --autostop-type <disabled|savestate|poweroff|acpishutdown>
su vbox
VBoxManage setproperty autostartdbpath /etc/vbox
VBoxManage modifyvm [servername 1] --autostart-enabled on
VBoxManage modifyvm [servername 2] --autostart-enabled on --autostart-delay 120
VBoxManage modifyvm [servername 3] --autostart-enabled on --autostart-delay 300
VBoxManage modifyvm [servername 1] --autostop-type savestate
VBoxManage modifyvm [servername 2] --autostop-type savestate
VBoxManage modifyvm [servername 3] --autostop-type savestate
Restart VirtualBox autostart service
su root
sudo service vboxautostart-service restart
Notes:
Virtualbox uses port 9000 to 9100 for VRDP, when you want to use Portainer in OMV you have to change these ports to another range for example 9100-9200. You can find these settings in phpvirtualbox, under settings of the VM, display -> remote display tab.
You can also change the parameter in the config.php of phpvirtualbox to reflect the correct ports:
Tested autoshutdown, now OMV waits until the machines are in "Saved State" before shutting the machine down. This works now. In OMV4 with the OMV-Extra's Virtualbox plugin installed the machines get aborted.
Good luck!!!
Regards, Roru69