Sunday, November 16, 2008

Portable Xampp

Running LAMP on a USB stick

Last year we decided to stop using IT services and teach programming by having students run LAMP from a usb stick using server2go. It was successful enough (despite some new technology problems) that we want use the same approach again. With larger and faster usb drives like the excellent Corsair Flash Voyager GT series this is now a useful option.

We had downloaded and installed the XAMPP stack on our linux laptop and were quite impressed by the excellent job done by the project team. The next step was to try running it on a usb stick using the portable apps project.

The portable apps web page has an installable XAMPP control panel which we added to our stick and then:

  1. Double click StartPortableApps.exe
  2. Click the portable apps icon on the taskbar
  3. Scroll down and click on Xampp control panel
  4. Place tickmarks in the Apache and mySQL services
  5. Click the start button for each service to start them
  6. Goto http://127.0.0.1/ Which laods the xampp/index.php (be sure to allow 127.0.0.1)
  7. The status menu item will let you know what is running.
On my first attempt mysql was not running so none of the demos worked.

The problem was that i had been running wampserver off the desktop the usb was plugged into. Although i had shutdown wampserver the apache webserver was still running which prevented xampp from operating correctly.

The solution was to go to control panel, administration, services and to change the wampapache service properties to manual and to shut down the service.

I then re-ran the xampp control panel from the portable apps menu and when we clicked on the status menu item we see mysql is running correctly on port 3306 and apache is running on port 80.

We try out the demo apps and they all work. The next task is to port some of my examples from the server to the usb stick. This involves:

- exporting the mysql database into a backup .sql file
- creating the users on the mysql usb database
- restoring the database from the backup.sql file
- copying the .php .css .htm and .jpg files from the application's folder to the usb stick

Sunday, November 9, 2008

Virtualbox Win95

Windows 95 on VirtualBox

I wanted to play an old game - Axis and Allies but it does not run on XP and the company has never released an updated version or even fixed the bugs. Hasbro has a habit of buying up the IP rights to classic board games and then releasing terrible computer games based on them (while preventing anyone else from releasing a good game!)

Anyway i decided as a test to install win95 on vb to see how it goes. The vb version is the closed one version 2.0.4

  1. Click New
  2. Give it a Name of Win95
  3. Select Windows 95 from the OS Type pulldown menu
  4. Allocate 128 mb of ram memory
  5. Click New in the Boot Hard Disk dialog box
  6. Choose Fixed Sized Image
  7. Make it 1 gig in size
  8. Click Finish

Note to self: The removal of the previous virtual box left the xp virtual machine as xp.vi in /home/gnickers/.VirtualBox/VDI - test and see if we can use this later!)

Click Start
Delect CD/DVD-ROM device abd Host Drive
Click Finish
We get 'no bootable medium found . System halted'
Insert the win95 install cd
We select Reset and press F12 and select CD-ROM

The error: 'Fatal: could not read from boot medium. System halted'
We shutdown the vm and restart with no change.

We try clicking on setup.exe from the cdrom0 window which runs the install program, but it says you cannot 'run setup from within windows NT'. This looks like it is running the install program - perhaps using Wine!

I seem to recall having the same problems last time i tried virtualbox - while setting up and installing vmware was more difficult, creating virtual machines seemed easier and more obvious using vmware than virtualbox.

Let's try to recover the old xp vm

  1. Select New
  2. Select Windows xp as the os type and call it xp
  3. Assign 512mb of ram
  4. Select the old xp.vdi as the boot hard disk
  5. Click Finish
  6. Click Start

Turns out the image does not work - xp starts to run but generates a bunch of errors. Expected really so we deleted the xp vm. Best check the xp.vdi to make sure the 10gig file gets deleted too!

Ok - now i remember the problem - the boot order is set to floppy drive (remember those?) and then to cd/dvd and the last time we did this we had the same problem.

  1. Click Settings, General
  2. Select the Advanced tab
  3. Untick the Floppy box (since we have no floppy drive...)
  4. We also do cd/dvd-rom and place a tick in Mount CD-DVD drive and also Audio, enable audio and set the audio to use the ALSA audio driver.

One annoyance is that an error message about 'usb services' comes up. We had the same problem with virtualbox 1.5.0 ose and the fix rather technical.

BTW - we notice that snapshots are stored in /home/gnickers.VirtualBox/Machines/Win95/snapshots for this vm.

Ok we put in the win95 cd and start up the vm. No joy. A complete waste of time so far. Probably because i forgot that windows 95 is so ancient it requires booting from a floppy before you can run the install. I wonder if i can install it by booting up a freedos vm and then running setup.exe. Maybe later.

Let's see if the XP install that worked before will still work again.

Installing XP on VirtualBox

First - Follow the instructions on enabling USB support BEFORE starting virtualbox

  1. Click New
  2. Set the memory (we have 4 gig so we gave xp 512k)
  3. Click New to create a virtual hard disk (10 gig is fine for a test install)
  4. Click Settings (If you get an error message about USB see below)
  5. Adjust the video memory size (16 or 32mb)
  6. Click the Advanced Tab and untick the floppy in Boot Order
  7. Click CD/DVD-Rom and select the mount cd/dvd radio button
  8. Select Audio and tick Enable Audio and select the ALSA Audio Driver
  9. Click USB and place a tick in the enable USB controller
Ok now we are ready to run the XP vm and install xp from the cd.

  1. Start the xp vm
  2. Put in the xp cd
  3. We see the message - press a key to boot from the CD
  4. We press a key and the xp installer runs
The rest is the boring xp install. However once the installer has run there are some housekeeping chores to do such as turning off the automatic updates, and security center, the remote access and all that other junk.


Virtualbox USB Fix

Select Applications, Accessories, terminal and enter:

sudo gedit /etc/init.d/mountdevsubfs.sh

Go to the lines as shown below:

#
# Magic to make /proc/bus/usb work
#
#mkdir -p /dev/bus/usb/.usbfs
#domount usbfs «» /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
#ln -s .usbfs/devices /dev/bus/usb/devices
#mount --rbind /dev/bus/usb /proc/bus/usb

Uncomment the last 4 lines by deleting the # marks to make it look like below:

#
# Magic to make /proc/bus/usb work
#
mkdir -p /dev/bus/usb/.usbfs
domount usbfs «» /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
ln -s .usbfs/devices /dev/bus/usb/devices
mount --rbind /dev/bus/usb /proc/bus/usb

Click SAVE
Select File, Quit

Now type this in terminal:

gksudo gedit /etc/udev/rules.d/40-permissions.rules

We then commented out the following system line by placing a # mark before it and added a # comment line saying when and why we made the change. We then copied the following line and edited out the # mark and did the following. Change:

SUBSYSTEM==»usb_device», MODE=»0664»

to

SUBSYSTEM==»usb_device», MODE=»0666»

We then did File, Save and exited the text editor.
And then rebooted the system

Now we Rerun virtualbox and when we click on SETTINGS there is no error message about USB.

Running VirtualBox

We were running virtualbox from the command line after the install by type VirtualBox which was a real annoyance. We wondered why the install did not add an entry to the system tools menu. As it turns out we were wrong - it DOES add a Sun xVM VirtualBox entry but NOT until you reboot!

Vritualbox on Ubuntu - update

VirtualBox Update

We went to run XP under virtualbox and found it was broken. Since we've been using ubuntu on the laptop we installed xp for those times we needed it, which has turned out to be not very much - so far we have not found anything we did on windows that we can't do on ubuntu. Since the summer there have been numerouse updates to the os but we have not run xp...

Anyway when starting up the xp virtual machine we got an error.

"virtualbox kernetl driver not installed.' The vboxdrv kernel module was either not loaded or /dev/vboxdrv was not created for some reason. Please install the virtualbox-ose-modules package for your kernet and execute /etc/init.d/vboxdrv start as root."

So off to the package manager we go to do a search for virtualbox. And we see that in fact we had installed the virtual-box-ose-module so maybe one of the updates broke this. Time to test out starting the vboxdrv module.

Off to Applications, Accessories, Terminal. Since starting the vboxdrv requires root priviledges we will use the sudo command.

barugon:~$ sudo /etc/init.d/vboxdrv start

Which gives us an error message about 'module vboxdrv not found'. Since modprobe (module probe) will not load a module unless it is installed first it looks like vboxdrv is not installed anymore. Should be re-install?

From the virtualbox help, about screen we see that we are using verison 1.5.0 and maybe the vbpxdrv module does not match my current linux kernel. Do we upgrade to 1.6.0 - but will upgrading destroy existing virtual machines? One would think not!

We go to the virtualbox downloads and see that it is at version 2.0.4 so we click to download the i386 version for Ubuntu 7.10 which automatically opens in the gDebi package manager. However, we get an error message: 'conflicts with teh installed package virtualbox-ose'.

Looks like we cannot do this directly. There is a note on the virtualbox web site that ubuntu users need to install the dkms package to ensure that the virtualbox host kernel module (vboxdrv) is properly updated if the linux kernel version changes during upgrades.

It seems likely this is what happened to us. Would have been useful it when installing virtualbox on ubunutu the package saw dkms as a 'dependency' and installed it. Will it work retroactively or do we have to remove the current version of virtualbox and reinstall the xp vm?

Back to the package manager to search for dkms which turns out to be the dynamic kernel module support framework and it was not installed. So we install it.

Now we retry the virtualbox-2.0 package but it gives the same error message. Oh well, let's deleted the existing vm's and remove the existing virtualbox installation and install the version 2 and then show how to install xp in class next week as a demo of a virtual machine installation.

We run virtualbox , select the xp vm and click Delete. We then run the package manager, search for virtualbox and mark the packages for removal.

Back to the virtualbox 2.0 download (just click the downloaded file in the firefox downloads window) and we click Install Package. It notes that "users of virtualbox must be members of the virtualbox group and host network interfaces will be assigned to that group."

A couple of Forwar clicks and the program installs itself.

Now we have to do the administrative tasks. Linux uses a different security model than windows (XP and lower) where everything basically has to have administrative rights. In Linux you can

We go to:

  1. System, administration, users and groups.
  2. Click on Manage Groups
  3. Select vboxusers
  4. Click properties
  5. Ensure the current user has a tick mark
  6. Click OK


One annoying thing it that the install did not add virtualbox to the applications, system menu. This is a long-standing annoyance with many linux installs - they seem to assume you know exactly where it installed...why? There are lots of places programs can install themselves to. Why i don't like the windows installer's habit of strewing icons across your desktop, the better installs ASK if you want an icon added to the menu and/or the desktop. Many linux installs do even do that. Why force people to have to hunt around the system trying to find out where the damn program is located so you can run it?



So how do you run it?

1. Run terminal (Applications, Accessories, Terminal)
2. VirtualBox

Note the capitalization of VirtualBox, you must type it exactly, else it the program will not be found. Linux is case-sensitive (unlike Windows) so that VirtualBox and virtualbox are different programs.

Once the program runs you have to agree to the EULA and register.


Next Step

Create a menu icon for VirtualBox so we don't have to run it from the terminal. But lunch first!



Appendix

Seeing how the version in the ubuntu repository is rather old, because there are two versions of Virtualbox, the open source one (ose) that gets included in distributions, and the more up to date closed version, which does not - so how do you keep up to date with virtualbox updates etc?
You have to add it to your list of repository sources.

Goto: http://www.virtualbox.org/wiki/Linux_Downloads
The easiest way seems to be to copy the following text from the web site and to open a terminal and paste it in:

wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -

To get some pre-built virtual machines for virtualbox goto:

http://virtualbox.wordpress.com/images/