0432.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Creating a Headless VirtualBox VM Host on Ubuntu Server</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Headless,How To,Hypervisor,Linux,PHPVirtualBox,Tutorial,Ubuntu,Ubuntu Server,VM,Virtual Machine,Virtual Machines,VirtualBox,VirtualBox Headless,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Creating a Headless VirtualBox VM Host on Ubuntu Server">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="03/09/2021 10:59:22 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Creating a Headless VirtualBox VM Host on Ubuntu Server</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>Installation and Configuration</h2>
  26. <ol>
  27. <li>Log into the Ubuntu Server host</li>
  28. <li>Run the following commands
  29. <div class="codeBlock"># update software repositories<br />
  30. sudo apt update<br />
  31. # install available software updates<br />
  32. sudo apt upgrade -y<br />
  33. # install virtualbox<br />
  34. sudo apt install virtualbox -y<br />
  35. # verify virtualbox installed by outputting the version<br />
  36. vboxmanage -version<br />
  37. # install virtualbox extension pack<br />
  38. sudo apt install virtualbox-ext-pack -y<br />
  39. # disable default vboxweb service<br />
  40. sudo systemctl disable vboxweb<br />
  41. # create vboxadmin user and set a password<br />
  42. sudo useradd vboxadmin<br />
  43. # set the vboxadmin password<br />
  44. sudo passwd vboxadmin<br />
  45. # add vboxadmin to the vboxuser group<br />
  46. sudo usermod -aG vboxusers vboxadmin<br />
  47. # create vboxadmin home directory<br />
  48. sudo mkdir /home/vboxadmin -p<br />
  49. # make vboxadmin the owner of the home directory<br />
  50. sudo chown -R vboxadmin /home/vboxadmin<br />
  51. # edit the default virtualbox configuration<br />
  52. sudo nano /etc/default/virtualbox</div>
  53. </li>
  54. <li>Add the following line to the bottom of the file, changing the username if necessary
  55. <p>VBOXWEB_USER=vboxadmin<br />
  56. VBOXWEB_HOST=127.0.0.1</p>
  57. </li>
  58. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  59. <li>Continue with the following commands, changing the username if necessary
  60. <div class="codeBlock"># create vboxweb.sh<br />
  61. sudo nano /home/vboxadmin/vboxweb.sh</div>
  62. </li>
  63. <li>Paste the following into vboxweb.sh
  64. <p>#!/bin/bash<br />
  65. /usr/bin/vboxwebsrv -H 127.0.0.1 &gt; /dev/null 2&gt;&amp;1</p>
  66. </li>
  67. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  68. <li>Continue with the following commands, changing the username if necessary
  69. <div class="codeBlock"># make vboxweb.sh executable<br />
  70. sudo chmod +x /home/vboxadmin/vboxweb.sh<br />
  71. # create phpvirtualbox.service<br />
  72. sudo nano /etc/systemd/system/phpvirtualbox.service</div>
  73. </li>
  74. <li>Paste the following service configuration, changing the username if necessary
  75. <p>[Unit]<br />
  76. Description=VirtualBox Web Service<br />
  77. After=network.target</p>
  78. <p>[Service]<br />
  79. Type=simple<br />
  80. RemainAfterExit=yes<br />
  81. User=vboxadmin<br />
  82. Group=vboxusers<br />
  83. WorkingDirectory=/home/vboxadmin<br />
  84. ExecStart=/home/vboxadmin/vboxweb.sh<br />
  85. Restart=on-failure</p>
  86. <p>[Install]<br />
  87. WantedBy=default.target</p>
  88. </li>
  89. <li>Continue with the following commands
  90. <div class="codeBlock"># enable phpvirtualbox.service<br />
  91. sudo systemctl enable phpvirtualbox.service<br />
  92. # start phpvirtualbox.service<br />
  93. sudo systemctl start phpvirtualbox.service<br />
  94. # install apache2 web server and php<br />
  95. 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 />
  96. # empty the apache2 web root<br />
  97. sudo rm /var/www/html/*<br />
  98. # install git<br />
  99. sudo apt install git -y<br />
  100. # clone phpVirtualBox git repository<br />
  101. sudo git clone https://github.com/phpvirtualbox/phpvirtualbox.git /var/www/html<br />
  102. # copy phpVirtualBox example config<br />
  103. sudo cp /var/www/html/config.php-example /var/www/html/config.php<br />
  104. # edit the config file<br />
  105. sudo nano /var/www/html/config.php</div>
  106. </li>
  107. <li>Update the $username and $password variables to vboxadmin and the password set for the vboxadmin user</li>
  108. <li>Press CTRL+O, Enter, CTRL+X to write the changes to config.php</li>
  109. <li>Open a web browser from another machine and navigate to https://DNSorIP of the VirtualBox host</li>
  110. <li>Log into phpVirtualBox with username admin and password admin</li>
  111. </ol>
  112. <h2>Creating a Test VM</h2>
  113. <ol>
  114. <li>Run the following command on the VirtualBox host to download the TinyCore Linux .iso
  115. <div class="codeBlock">sudo wget -O /home/vboxadmin/TinyCore-12.0.iso http://tinycorelinux.net/12.x/x86/release/TinyCore-12.0.iso</div>
  116. </li>
  117. <li>In the phpVirtualBox web UI, click New</li>
  118. <li>Set the Name to TinyCore Linux, Type to Linux and Version to Other Linux (32-bit) &gt; Click Next</li>
  119. <li>Leave the memory at 256 MB &gt; Click Next</li>
  120. <li>Select Do not add a virtual hard disk &gt; Click Create</li>
  121. <li>Click Continue to confirm creating the VM with no virtual hard disk</li>
  122. <li>Right click the TinyCore Linux VM &gt; Settings...</li>
  123. <li>Select Storage from the left navigation menu</li>
  124. <li>Click on the empty optical drive</li>
  125. <li>Click the choose disk image dropdown &gt; Choose a virtual disk file...</li>
  126. <li>Navigate to /home/vboxadmin/TinyCore-12.0.iso and select it</li>
  127. <li>Click OK to all open dialog windows</li>
  128. <li>Right click the TinyCore Linux VM &gt; Start</li>
  129. <li>If everything is working as expected TinyCore Linux should be booting to the live environment</li>
  130. <li>Look at the Display details to find the remote port (starts at 9000 by default)</li>
  131. <li>To view the VM directly, remote desktop to the VirtualBox host IP:9000</li>
  132. </ol>
  133. </div>
  134. </div>
  135. </body>
  136. </html>