Managing A Headless VirtualBox Installation With phpvirtualbox On nginx (Ubuntu 12.04)
|
Submitted by falko (Contact Author) (Forums) on Tue, 2012-08-21 17:37. :: Ubuntu | VirtualBox | Web Server | nginx | Virtualization
Managing A Headless VirtualBox Installation With phpvirtualbox On nginx (Ubuntu 12.04)Version 1.0 phpvirtualbox is a web-based VirtualBox front-end written in PHP that allows you to access and control remote VirtualBox instances. It tries to resemble the VirtualBox GUI as much as possible to make work with it as easy as possible. It is a nice replacement for the VirtualBox GUI if you run VirtualBox in headless servers (like in the tutorial VBoxHeadless - Running Virtual Machines With VirtualBox 4.1 On A Headless Ubuntu 12.04 Server). This tutorial explains how to install phpvirtualbox with nginx on an Ubuntu 12.04 server to manage a locally installed, headless VirtualBox. I do not issue any guarantee that this will work for you!
1 Preliminary NoteI'm assuming that a headless VirtualBox is already installed on the local Ubuntu 12.04 server, e.g. as described in the tutorial VBoxHeadless - Running Virtual Machines With VirtualBox 4.1 On A Headless Ubuntu 12.04 Server. I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root: sudo su
2 Installing phpvirtualboxFirst create a system user called vbox and add it to the vboxusers group: useradd -m vbox -G vboxusers Create a password for the vbox user: passwd vbox Create the file /etc/default/virtualbox and put the line VBOXWEB_USER=vbox in it (so that the VirtualBox SOAP API which is called vboxwebsrv runs as the user vbox): vi /etc/default/virtualbox
Next create the system startup links for vboxwebsrv and start it: update-rc.d vboxweb-service defaults We need a web server with PHP support to serve phpvirtualbox - I'm using nginx here. Install nginx and PHP5 as follows: apt-get install nginx php5-common php5-mysql php5-suhosin php5-fpm php-pear wget Start nginx: /etc/init.d/nginx start The virtual hosts are defined in server {} containers. The default vhost is defined in the file /etc/nginx/sites-available/default - let's modify it as follows so that it can server PHP files: vi /etc/nginx/sites-available/default
Uncomment both listen lines to make nginx listen on port 80 IPv4 and IPv6. server_name _; makes this a default catchall vhost (of course, you can as well specify a hostname here like www.example.com). I've added index.php to the index line. root /usr/share/nginx/www; means that the document root is the directory /usr/share/nginx/www. The important part for PHP is the location ~ \.php$ {} stanza. Uncomment it to enable it. Please note that I've added the line try_files $uri =404; to prevent zero-day exploits (see http://wiki.nginx.org/Pitfalls#Passing_Uncontrolled_Requests_to_PHP and http://forum.nginx.org/read.php?2,88845,page=3). Alternatively, if you don't want to use the try_files $uri =404; line, you can set cgi.fix_pathinfo = 0; in /etc/php5/fpm/php.ini (don't forget to reload PHP-FPM afterwards). Now save the file and reload nginx: /etc/init.d/nginx reload I want to serve phpvirtualbox from the nginx default virtual host with the document root /usr/share/nginx/www (I will install it in /usr/share/nginx/www/phpvirtualbox) - if you have a different document root, you must adjust the following steps: cd /usr/share/nginx/www Make sure unzip is installed: apt-get install unzip Unzip phpvirtualbox and rename the phpvirtualbox-4.1-8 to phpvirtualbox for ease of use: unzip phpvirtualbox-4.1-8.zip Next go to the /var/www/phpvirtualbox/ directory... cd /usr/share/nginx/www/phpvirtualbox/ ... and create the file config.php by copying it from config.php-example: cp config.php-example config.php Open config.php and fill in the password you created earlier for the vbox system user: vi config.php
That's it already - you can now open a browser and access phpvirtualbox as follows: http://www.example.com/phpvirtualbox/ The default username is admin, the password is admin as well: This is how phpvirtualbox looks - much like the native VirtualBox GUI: The first thing you should do is change the admin password. Go to File > Change Password: Type in the old password and specify a new one: If you know the native VirtualBox GUI, it's now very easy to use phpvirtualbox. For example, if you want to create a new virtual machine, you have the same wizard as you have in the VirtualBox GUI: (I'm leaving a few sceenshots out so you don't feel bored...)
|











Recent comments
5 hours 43 min ago
15 hours 11 min ago
16 hours 1 min ago
19 hours 34 min ago
23 hours 58 min ago
1 day 20 min ago
1 day 2 hours ago
1 day 12 hours ago
1 day 17 hours ago
1 day 18 hours ago