Few days ago we described how to install VirtualBox 5.2 on a headless Ubuntu 16.04 LTS server… Headless servers are those you’re not directly connected to using monitors and usually sit in remote locations..
With VirtualBox installed on a headless server, you’ll need to tool to help creating and managing virtual guest machines easily… One can use remote desktop connection as we described in our previous post, but if you need to manage multiple guest machine, then phpVirtualBox is a way to go..
Again, Virtualization software like VirtualBox and VMware Workstation Pro or VMware Players allow users to run multiple guest operating systems simultaneously on a single host computer.
We’ve also described instructions to install these popular virtualization software on Ubuntu and Windows systems on this website.
To get started with managing VirtualBox headless servers via phpVirtualBox, continue below:
Step 1: Prerequisites – Install VirtualBox
Before you can install phpVirtualBox, you must first install VirtualBox. The link below shows you how to do just that.
Now that VirtualBox is installed, your next step is to get phpVirtualBox installed.
Step 2: Install Apache2 HTTP Server
After installing VirtualBox as described in our previous post, run the commands below to install Apache2 HTTP server.
sudo apt install apache2
Step 3: Install PHP 7.1 and Related Modules
PHP 7.1 isn’t available on Ubuntu default repositories… in order to install it, you will have to get it from third-party repositories.
Run the commands below to add the below third party repository to upgrade to PHP 7.1
sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php
Then update and upgrade to PHP 7.1
sudo apt update
Run the commands below to install PHP 7.1 and related modules.
sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common libapache2-mod-php7.1 php7.1-mbstring php7.1-soap php7.1-xml php7.1-mysql php7.1-cli
After installing PHP 7.1 modules, run the commands below to open Apache2 PHP default configuration file.
sudo nano /etc/php/7.1/apache2/php.ini
Then add the lines below just before Dynamic Extensions
Save the file and exit.
Reload Apache2 HTTP Server
sudo systemctl reload apache2.service
Step 4: Install phpVirtualBox
Finally, run the commands below to download phpVirtualBox package
cd /tmp && wget https://sourceforge.net/projects/phpvirtualbox/files/phpvirtualbox-5.0-5.zip
After downloading, run the commands below to unzip the package, and copy it to Apache2 default document root directory.
unzip phpvirtualbox-5.0-5.zip sudo mv phpvirtualbox-5.0-5 /var/www/html/phpvirtualbox
Next, create phpVirtualBox configuration file from its sample file by running the commands below.
sudo cp /var/www/html/phpvirtualbox/config.php-example /var/www/html/phpvirtualbox/config.php
Step 6: Create phpVirtualBox dedicated user account
phpVirtualBox requires dedicated user account to manage the VirtualBox. For that, you need to create a service account.
To create a service account called vbox and add the user to the vboxusers group… by runing the commands below and run the second line to create a new password.
sudo useradd -m vbox -G vboxusers sudo passwd vbox
Next, set the permissions for the phpVirtualBox directory for vbox user
sudo chown -R vbox:vboxusers /var/www/html/phpvirtualbox sudo chmod -R 755 /var/www/html/phpvirtualbox
Step 7: Setup phpVirtualBox connection
The final step is to configure phpVirtualBox user connection. This can be done by opening its default configuration file and adding phpvbox user to the settings.
Open and edit the file by running the commands below:
sudo nano /var/www/html/phpvirtualbox/config.php
Then fill in the user account for phpvbox as shown below.
/* Username / Password for system user that runs VirtualBox */
var $username = ‘vbox‘;
var $password = ‘vbox_password‘;
var $location = ‘http://localhost:18083/’;
Next, run the commands below to open VirtualBox config file in the /etc/default directory.
sudo nano /etc/default/virtualbox
Then add this lines at the end of the file, then save it. This allows VirtualBox SOAP API service to run as vbox.
Start the phpVirtualBox service account by running the commands below.
sudo systemctl enable vboxwebsrv.service sudo systemctl start vboxwebsrv.service sudo systemctl reload apache2.service
Restart Apache2 server, then browse to the host via IP or hostname followed by /phpvirtualbox
This is how to manage VirtualBox remotely.
You may also like the post below:
- Students Tutorial – FeedBurner for WordPress with Apache2 Redirect
- Students Tutorial – Allow WordPress Permalinks on Nginx or Apache2
- Students Tutorial – Setup Ubuntu Linux with Apache2, MariaDB and PHP (LAMP)
- Redirect HTTP to HTTPS using Nginx or Apache2 on Ubuntu 17.04
- Apache2 301 Redirect Without htaccess File on Ubuntu 17.04
- Setting up SSL/TLS for Apache2 on Ubuntu 17.04
- Install Apache2 and Disable Directory Listing on Ubuntu
- Quickly Get LetsEncrypt Certificates for Apache2 on Ubuntu 17.04 /17.10
- Switch from Apache2 to Nginx to Run WordPress on Ubuntu 17.04 / 17.10