Install phpVirtualBox on CentOS 7.x

I have to say, I have been bursting with some excitement to recently discover this gem. phpVirtualBox is going to make a great addition to my server by allowing me to create and manage VirtualBox VM’s direct from my web browser. So just a small guide, sticking with the theme, on getting phpVirtualBox installed and running on CentOS 7.x.

Install required packages

Install Apache Web Server

Start Apache and ensure it starts automatically on boot.

Finally, add an exception in the firewall so that you can access Apache over HTTP and HTTPS.

Test that Apache is running and accessible by opening a browser and navigating to http://server_ip_address.

Install PHP

Restart Apache.

Test that PHP is working by creating a PHP test file that will display the PHP information page (watch out for the quotes if copy/pasting).

Verify that the PHP information page loads by opening a browser and navigating to http://server_ip_address/test.php.

Create phpVirtualBox User Account

Create the account that the virtualbox web service will run as and to be used by phpVirtualBox.

Install phpVirtualBox

Download the latest stable phpVirtualBox package (5.2-0-rc1 at the time of writing)

Unzip/Extract phpVirtualBox package.

Configure phpVirtualBox

Edit phpVirtualBox config.php file:

Change the username/password to the user that runs the VirtualBox web service.

Set the user that the VirtualBox web service will run as.

Restart the VirtualBox web service

Add SELinux Policy Exception

If you prefer not to disable SELinux then a policy exception will need to be added that allows phpVirtualBox to connect to the VirtualBox web service. First install the ‘policycoreutils-python’ package, which provides ‘semanage’.

Run the following command to add the exception.

Open a browser and to http://server_ip_address/phpvirtualbox. I’d recommend to use Firefox if you plan on using the console as this uses Flash, which will be blocked by Chrome. Use the default login username: admin and password: admin.

Accessing the Virtual Machine Console Remotely

You will have the capability to access the virtual machine console (to perform assisted installation, access the VM for troubleshooting, etc) using the rdesktop session through phpvirtualbox. You must enable ‘Remote Display’ support on the virtual machine settings, under ‘Display’. The port range defaults to 9000-9100, which should be fine unless you plan to run more VMs :).

In addition to enabling this feature, you will need to add an exception in the firewall to allow your client (web browser) to access the console.

You should now be able to access the VM’s console.

One final note. When connecting to the console, ensure to change the ‘Requested desktop size’ to ‘1024×768’ so that you are able to view the console properly.

3
Leave a Reply

avatar
2 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
Gavin StephensVictor MRoel Recent comment authors
  Subscribe  
Notify of
Roel
Guest
Roel

Links are not working! Bad howto!

Victor M
Guest
Victor M

I follow instructions and phpVirtualBox is working!!!
Thanks!!!