Creating a Headless VirtualBox VM Host on Ubuntu Server
#VirtualBox #Hypervisor
Full steps can be found at https://i12bretro.github.io/tutorials/0432.html
Installation and Configuration
01. Log into the Ubuntu Server host
02. Run the following commands
# update software repositories
sudo apt update
# install available software updates
sudo apt upgrade -y
# install virtualbox
sudo apt install virtualbox -y
# verify virtualbox installed by outputting the version
vboxmanage -version
# install virtualbox extension pack
sudo apt install virtualbox-ext-pack -y
# disable default vboxweb service
sudo systemctl disable vboxweb
# create vboxadmin user and set a password
sudo useradd vboxadmin
# set the vboxadmin password
sudo passwd vboxadmin
# add vboxadmin to the vboxuser group
sudo usermod -aG vboxusers vboxadmin
# create vboxadmin home directory
sudo mkdir /home/vboxadmin -p
# make vboxadmin the owner of the home directory
sudo chown -R vboxadmin /home/vboxadmin
# edit the default virtualbox configuration
sudo nano /etc/default/virtualbox
03. Add the following line to the bottom of the file, changing the username if necessary
VBOXWEB_USER=vboxadmin
VBOXWEB_HOST=127.0.0.1
04. Press CTRL+O, Enter, CTRL+X to write the changes
05. Continue with the following commands, changing the username if necessary
# create vboxweb.sh
sudo nano /home/vboxadmin/vboxweb.sh
06. Paste the following into vboxweb.sh
#!/bin/bash
/usr/bin/vboxwebsrv -H 127.0.0.1 ≫ /dev/null 2≫&1
07. Press CTRL+O, Enter, CTRL+X to write the changes
08. Continue with the following commands, changing the username if necessary
# make vboxweb.sh executable
sudo chmod +x /home/vboxadmin/vboxweb.sh
# create phpvirtualbox.service
sudo nano /etc/systemd/system/phpvirtualbox.service
09. Paste the following service configuration, changing the username if necessary
[Unit]
Description=VirtualBox Web Service
After=network.target
[Service]
Type=simple
RemainAfterExit=yes
User=vboxadmin
Group=vboxusers
WorkingDirectory=/home/vboxadmin
ExecStart=/home/vboxadmin/vboxweb.sh
Restart=on-failure
[Install]
WantedBy=default.target
10. Continue with the following commands
# enable phpvirtualbox.service
sudo systemctl enable phpvirtualbox.service
# start phpvirtualbox.service
sudo systemctl start phpvirtualbox.service
# install apache2 web server and php
sudo apt install apache2 php libapache2-mod-php php-curl php-intl php-json php-gd php-mbstring php-xml php-zip php-soap -y
# empty the apache2 web root
sudo rm /var/www/html/*
# install git
sudo apt install git -y
# clone phpVirtualBox git repository
sudo git clone https://github.com/phpvirtualbox/phpvirtualbox.git /var/www/html
# copy phpVirtualBox example config
sudo cp /var/www/html/config.php-example /var/www/html/config.php
# edit the config file
sudo nano /var/www/html/config.php
11. Update the $username and $password variables to vboxadmin and the password set for the vboxadmin user
12. Press CTRL+O, Enter, CTRL+X to write the changes to config.php
13. Open a web browser from another machine and navigate to https://DNSorIP of the VirtualBox host
14. Log into phpVirtualBox with username admin and password admin
Creating a Test VM
01. Run the following command on the VirtualBox host to download the TinyCore Linux .iso
sudo wget -O /home/vboxadmin/TinyCore-12.0.iso http://tinycorelinux.net/12.x/x86/release/TinyCore-12.0.iso
02. In the phpVirtualBox web UI, click New
03. Set the Name to TinyCore Linux, Type to Linux and Version to Other Linux (32-bit) ≫ Click Next
04. Leave the memory at 256 MB ≫ Click Next
05. Select Do not add a virtual hard disk ≫ Click Create
06. Click Continue to confirm creating the VM with no virtual hard disk
07. Right click the TinyCore Linux VM ≫ Settings...
08. Select Storage from the left navigation menu
09. Click on the empty optical drive
10. Click the choose disk image dropdown ≫ Choose a virtual disk file...
11. Navigate to /home/vboxadmin/TinyCore-12.0.iso and select it
12. Click OK to all open dialog windows
13. Right click the TinyCore Linux VM ≫ Start
14. If everything is working as expected TinyCore Linux should be booting to the live environment
....Full steps can be found on GitHub [link at the top]
### Connect with me and others ###
★ Discord: https://discord.com/invite/EzenvmSHW8
★ Reddit: https://reddit.com/r/i12bretro
★ Twitter: https://twitter.com/i12bretro