|
@@ -0,0 +1,142 @@
|
|
|
+ <!DOCTYPE html>
|
|
|
+ <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
|
|
+ <head>
|
|
|
+ <title>Creating a Headless VirtualBox VM Host on Ubuntu Server</title>
|
|
|
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="keywords" content="Headless,How To,Hypervisor,Linux,PHPVirtualBox,Tutorial,Ubuntu,Ubuntu Server,VM,Virtual Machine,Virtual Machines,VirtualBox,VirtualBox Headless,i12bretro">
|
|
|
+ <meta name="author" content="i12bretro">
|
|
|
+ <meta name="description" content="Creating a Headless VirtualBox VM Host on Ubuntu Server">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <meta name="revised" content="03/09/2021 10:59:22 AM" />
|
|
|
+ <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
|
|
|
+ <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
|
|
+ <script type="text/javascript" src="includes/js/steps.js"></script>
|
|
|
+ <link href="css/steps.css" rel="stylesheet" type="text/css" />
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <div id="gridContainer">
|
|
|
+ <div class="topMargin"></div>
|
|
|
+ <div id="listName" class="topMargin">
|
|
|
+ <h1>Creating a Headless VirtualBox VM Host on Ubuntu Server</h1>
|
|
|
+ </div>
|
|
|
+ <div></div>
|
|
|
+ <div id="content">
|
|
|
+ <h2>Installation and Configuration</h2>
|
|
|
+
|
|
|
+<ol>
|
|
|
+ <li>Log into the Ubuntu Server host</li>
|
|
|
+ <li>Run the following commands
|
|
|
+ <div class="codeBlock"># update software repositories<br />
|
|
|
+ sudo apt update<br />
|
|
|
+ # install available software updates<br />
|
|
|
+ sudo apt upgrade -y<br />
|
|
|
+ # install virtualbox<br />
|
|
|
+ sudo apt install virtualbox -y<br />
|
|
|
+ # verify virtualbox installed by outputting the version<br />
|
|
|
+ vboxmanage -version<br />
|
|
|
+ # install virtualbox extension pack<br />
|
|
|
+ sudo apt install virtualbox-ext-pack -y<br />
|
|
|
+ # disable default vboxweb service<br />
|
|
|
+ sudo systemctl disable vboxweb<br />
|
|
|
+ # create vboxadmin user and set a password<br />
|
|
|
+ sudo useradd vboxadmin<br />
|
|
|
+ # set the vboxadmin password<br />
|
|
|
+ sudo passwd vboxadmin<br />
|
|
|
+ # add vboxadmin to the vboxuser group<br />
|
|
|
+ sudo usermod -aG vboxusers vboxadmin<br />
|
|
|
+ # create vboxadmin home directory<br />
|
|
|
+ sudo mkdir /home/vboxadmin -p<br />
|
|
|
+ # make vboxadmin the owner of the home directory<br />
|
|
|
+ sudo chown -R vboxadmin /home/vboxadmin<br />
|
|
|
+ # edit the default virtualbox configuration<br />
|
|
|
+ sudo nano /etc/default/virtualbox</div>
|
|
|
+ </li>
|
|
|
+ <li>Add the following line to the bottom of the file, changing the username if necessary
|
|
|
+ <p>VBOXWEB_USER=vboxadmin<br />
|
|
|
+ VBOXWEB_HOST=127.0.0.1</p>
|
|
|
+ </li>
|
|
|
+ <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
|
|
|
+ <li>Continue with the following commands, changing the username if necessary
|
|
|
+ <div class="codeBlock"># create vboxweb.sh<br />
|
|
|
+ sudo nano /home/vboxadmin/vboxweb.sh</div>
|
|
|
+ </li>
|
|
|
+ <li>Paste the following into vboxweb.sh
|
|
|
+ <p>#!/bin/bash<br />
|
|
|
+ /usr/bin/vboxwebsrv -H 127.0.0.1 > /dev/null 2>&1</p>
|
|
|
+ </li>
|
|
|
+ <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
|
|
|
+ <li>Continue with the following commands, changing the username if necessary
|
|
|
+ <div class="codeBlock"># make vboxweb.sh executable<br />
|
|
|
+ sudo chmod +x /home/vboxadmin/vboxweb.sh<br />
|
|
|
+ # create phpvirtualbox.service<br />
|
|
|
+ sudo nano /etc/systemd/system/phpvirtualbox.service</div>
|
|
|
+ </li>
|
|
|
+ <li>Paste the following service configuration, changing the username if necessary
|
|
|
+ <p>[Unit]<br />
|
|
|
+ Description=VirtualBox Web Service<br />
|
|
|
+ After=network.target</p>
|
|
|
+
|
|
|
+ <p>[Service]<br />
|
|
|
+ Type=simple<br />
|
|
|
+ RemainAfterExit=yes<br />
|
|
|
+ User=vboxadmin<br />
|
|
|
+ Group=vboxusers<br />
|
|
|
+ WorkingDirectory=/home/vboxadmin<br />
|
|
|
+ ExecStart=/home/vboxadmin/vboxweb.sh<br />
|
|
|
+ Restart=on-failure</p>
|
|
|
+
|
|
|
+ <p>[Install]<br />
|
|
|
+ WantedBy=default.target</p>
|
|
|
+ </li>
|
|
|
+ <li>Continue with the following commands
|
|
|
+ <div class="codeBlock"># enable phpvirtualbox.service<br />
|
|
|
+ sudo systemctl enable phpvirtualbox.service<br />
|
|
|
+ # start phpvirtualbox.service<br />
|
|
|
+ sudo systemctl start phpvirtualbox.service<br />
|
|
|
+ # install apache2 web server and php<br />
|
|
|
+ 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<br />
|
|
|
+ # empty the apache2 web root<br />
|
|
|
+ sudo rm /var/www/html/*<br />
|
|
|
+ # install git<br />
|
|
|
+ sudo apt install git -y<br />
|
|
|
+ # clone phpVirtualBox git repository<br />
|
|
|
+ sudo git clone https://github.com/phpvirtualbox/phpvirtualbox.git /var/www/html<br />
|
|
|
+ # copy phpVirtualBox example config<br />
|
|
|
+ sudo cp /var/www/html/config.php-example /var/www/html/config.php<br />
|
|
|
+ # edit the config file<br />
|
|
|
+ sudo nano /var/www/html/config.php</div>
|
|
|
+ </li>
|
|
|
+ <li>Update the $username and $password variables to vboxadmin and the password set for the vboxadmin user</li>
|
|
|
+ <li>Press CTRL+O, Enter, CTRL+X to write the changes to config.php</li>
|
|
|
+ <li>Open a web browser from another machine and navigate to https://DNSorIP of the VirtualBox host</li>
|
|
|
+ <li>Log into phpVirtualBox with username admin and password admin</li>
|
|
|
+</ol>
|
|
|
+
|
|
|
+<h2>Creating a Test VM</h2>
|
|
|
+
|
|
|
+<ol>
|
|
|
+ <li>Run the following command on the VirtualBox host to download the TinyCore Linux .iso
|
|
|
+ <div class="codeBlock">sudo wget -O /home/vboxadmin/TinyCore-12.0.iso http://tinycorelinux.net/12.x/x86/release/TinyCore-12.0.iso</div>
|
|
|
+ </li>
|
|
|
+ <li>In the phpVirtualBox web UI, click New</li>
|
|
|
+ <li>Set the Name to TinyCore Linux, Type to Linux and Version to Other Linux (32-bit) > Click Next</li>
|
|
|
+ <li>Leave the memory at 256 MB > Click Next</li>
|
|
|
+ <li>Select Do not add a virtual hard disk > Click Create</li>
|
|
|
+ <li>Click Continue to confirm creating the VM with no virtual hard disk</li>
|
|
|
+ <li>Right click the TinyCore Linux VM > Settings...</li>
|
|
|
+ <li>Select Storage from the left navigation menu</li>
|
|
|
+ <li>Click on the empty optical drive</li>
|
|
|
+ <li>Click the choose disk image dropdown > Choose a virtual disk file...</li>
|
|
|
+ <li>Navigate to /home/vboxadmin/TinyCore-12.0.iso and select it</li>
|
|
|
+ <li>Click OK to all open dialog windows</li>
|
|
|
+ <li>Right click the TinyCore Linux VM > Start</li>
|
|
|
+ <li>If everything is working as expected TinyCore Linux should be booting to the live environment</li>
|
|
|
+ <li>Look at the Display details to find the remote port (starts at 9000 by default)</li>
|
|
|
+ <li>To view the VM directly, remote desktop to the VirtualBox host IP:9000</li>
|
|
|
+</ol>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </body>
|
|
|
+ </html>
|
|
|
+
|