Tuesday, March 6, 2012

phpVirtualBox on OpenSuSE 12.x

phpVirtualBox home page is in http://code.google.com/p/phpvirtualbox/. It is just a web interface which is written in php that controls, access and monitor your vms. In short a browser that controls your vms. You will need to install VirtualBox since it is  just a front end. Refer to my guide on how you can install vbox. One more thing to note is that the package from the distro does not have vboxwebsrv  this works only for the binary from Oracle. After you have installed vbox you will install a web server. We will use apache2 as an example. You can either use yast2 software management to install the lamp_server pattern and some php packages or use our friend zypper.

  • To install the packages using zypper
     .     zypper in patterns-openSUSE-lamp_server php5-soap      
    • Download the package using the wget utility while your are a normal user in your home directory
     .     wget http://phpvirtualbox.googlecode.com/files/phpvirtualbox-4.1-5.zip 
    •  Unpack that zip file using unzip into your public_html directory.
          unzip phpvirtualbox-4.1-5.zip -d ~/public_html/ && cd ~/public_html 
    • Rename that file to just phpvirtualbox
        . mv phpvirtualbox-4.1-5 phpvirtualbox && cd phpvirtualbox 

    • Now rename the php file
        mv config.php-example config.php 

    • Edit that config.php file and put the name of the user which uses virtualbox and the corresponding line and do it like this.
      var $username = 'jetchisel';                                  
      var $password = 'mypassword';

      var $ location = '';  

     var $consoleHost = 'IP ADDRESS OF YOUR COMPUTER'; 

    • Start apache2, as root
    r         rcapache2 start 
    • 12.1 and up use: 
              systemctl start apache2.service 

    This should open port 80 for http, a simple   nmap localhost   before and after you run that command will tell you if the port is open or not. If if does not open it, you can use   yast2 firewall   to open the port manually as shown below.

    • Start vboxwebsrv as a normal user.
                      vboxwebsrv -b  

    • Check if vboxweb is indeed running.

     grep vboxwebsrv < <(ps aux)
    1000 3284 0.1  0.2 562672 6056 ?  Sl 17:04 0:01 /usr/lib/virtualbox/vboxwebsrv -b

    • Use pgrep to check the pid of vboxwebsrv.

     pgrep -x vboxwebsrv -u "$EUID" 
    • On your browser put the following address, just don't put my nick in there :-) replace it with your own.

    username = admin
    password = admin

    You can run this command   rdesktop-vrdp -xl -z localhost:3389  to access your vm once it is running since all the vms that will start from this web interface is headless.The port 3389 is the default settings in vbox once you have done it on the settings, but you can always change it to whatever port you want.
    The good thing is that there is a built in  console button at the right end corner of the web interface which you can use to connect also :-) .

    You can try to access phpvbox from within your lan provided that you have open http port on the firewall. You can stop the firewall completely as root run

    • 12.1 and up use:
           systemctl stop SuSEfirewall2_init.service 

    • Other versions use  
          /sbin/SuSEfirewall2 stop 

                                                             Change the port as well

    If you get an error that say's cannot connect to vboxwebsrv then you can run VBoxManage as a normal user.  DO NOT run VBoxManage as root!!!

        VBoxManage setproperty websrvauthlibrary default
        VBoxManage setproperty websrvauthlibrary null

    Check if vboxweb is running and if you have more than one vboxweb running you can kill that process as a normal user run   pkill vboxwebsrv  and restart apache2 as root run  rcapache2 restart    then start again from the beginning. 

    The end :-)

    This guide only uses the user's home public_html directory for phpvbox and not in    /srv/www/htdocs   which is the default location of the document root files from apache2 in openSUSE. Messing with it means you have to be root, which means you should know what you are doing. If your just trying it out for the first time then this set up should be enough. This software is developing so expect some good changes, also keep in mind that future release may not work as expected from this guide and last but not least it may have some rpm packages in the future provided someone will package this for OpenSuSE.

    Enjoy folks!

    Kudos to Mr. Ian Moore the author of phpvirtualbox.

    My reloaded phpvirtualbox howto.


    The documentation for linux configuration of phpvirtualbox you can find in this site.


    1. Nice how-to ! congrats.

      To setup vboxwebservice follow this wiki: