Sunday, August 30, 2009

XAMPP on a CD

Xampp on a CD

The goal today is to produce a self-running cd-rom containing the XAMPP stack along with joomla so that students can burn their projects running on a USB stick to a CD-ROM.

Requirements:

  • USB stick running xampp with joomla installed
  • AMPstart software (replaces the xampp control panel)
  • autorun.inf file
  • autorun.bat file
  • ampstart.ini file
  • cd-rom burning software
The autorun.inf file consists of:

[autorun] open=autorun.bat icon=joomla.png Label=server

I created a small icon of 32x32 pixels. When ampstart is running the icon is in the windows system tray. Double-click on the icon to shut down the web server and unlock the cd tray.

The autorun.bat file consists of:

@echo off rem script to make auto-run xampp joomla lis 9710 cd rem creates a mysql data dir on c because mysql needs a writable folder mkdir c:\mysql\data xcopy xampp\mysql\data\ c:\mysql\data /E start AMPstart.exe

the ampstart.ini file consists of:

[database] overwrite=1 folder=c:\mysql\data [website] website=htdocs\joomla startup=index.php port= [cd] eject=1

The eject option ejects the cd when the web server is shut down. Will it work? Our previous attempts at running from a cd failed and this is when we started researching ampstart. There are some other options we might add later to the .ini file if this works.

[WEBSITE]
website=\path\to\web\app

You can also auto open firefox if it is not the default web browser with:

[WEBSITE]
ExtBrowser=\path\to\browser\executable\file

If you want to make the site seem more realistic in a demo (such as a real looking url instead of localhost) use:

[WEBSITE]
ServerName=somedomain
website=\path\to\web\app

To auto shut down the web server when the web apps ends use:

[WEBSITE]
ShutdownOnClose=1

And to set the duration for the ampstart splash screen use:

[LOGO]
duration=n_second
;default 0 (depending on loading time of web server)

Ok so here we go - burn the cd from the usb stick. Here is the folder structure. It suddenly occurs to me that we have been closing the disc so that it is read-only. What is we made the disc a multi-session? Could mysql then write to its data directory on the cd?

Might be worth trying if this test fails.

Ok and it fails because it could not copy the mysql data folder to the c: drive. Why? Let's step thru the command one by one in the windows shell. The mkdir command works as their is a c:\mysql\data folder. The xcopy fails with an invalid path error. Time to haul out the ms-dos manual...ahhh i'm using the /E switch but it requires the /S switch:

/S - Copies all files in the current directory and in any subdirectory within it.
/E - Copies subdirectories, even if they are empty. If you use this option, you must use the /S option also.

But that doesn't account for the 'path' error. If i change directories to xampp\mysql\data and end up with a pwd of \xampp\mysql\data then the xcopy command works perfectly. But when executed from the root of the usb stick it fails. Ok, this suggests a workaround - just cd into the data folder and then run the xcopy command, a hack but quicker than trying to recall how ms-dos works. So out new autorun.bat looks like:

@echo off
rem script to make auto-run xampp joomla cd
rem creates a mysql data dir on c because mysql needs it
mkdir c:\mysql\data
cd \xampp\mysql\data
xcopy *.* c:\mysql\data /E /S /C
cd \
start AMPstart.exe


Ok - time to burn another CD. This one fails too - mysql error 'could not make a copy' but it did make a copy. The webserver app then just tries to run and fails. Since ampstart is running maybe the error is from the ampstart.ini file. Let's change that to:

[database]
overwrite=0
folder=c:\mysql\data

[website]
website=htdocs\joomla
startup=index.php
port=

[cd]
eject=1

Ok burn another CD...which fails with 'cannot load mysql'. I went looking for the ampstart site but the domain name seems to have lapsed. But the search turned up Lampix, a bootable cd based on knoppix. See: http://lamppix.tinowagner.com/ But it hasn't been updated since 2007 and getting your files from the USB stick to the CD is more work than we want to do. There must be a solution somewhere...

Of course they could just hand in their projects on USB sticks but until they are less than $5 a gig this is not a realistic option...

Monday, August 24, 2009

Dell Mini 9 Ubuntu Update

I've been using the dell mini 9 for a month or so now and it's time to upgrade it to ubuntu 9. The rationale is:

  • the dell ubuntu install is version 8 so it is old
  • it uses the dell repositories so not many updates
  • samba was broken on install, which is unforgivable as we have to coexist with windows

So time to update to 9. The question is how - we have the 9 cd and a usb dvd so we could go that route or we could do the notebook remix route and use the USB key method which is appealing.

First we get a torrent and download ubuntu-9.04-netbooks-remix-i386.img which is an image to be burned to a usb stick. Next, off to the package manager to install usb-imagewriter version 0.1.3 from the repository. We put in a 2 gig spare stick and run the program using:

Applications, Accessories, Image Writer

It returns an error 'no target devices found'. So it did not find a USB stick. We note the mounted stick does not have the orange usb symbol on it so we unmount it and plug it into another usb port. We check and this is listed as /dev/sdb

Re-running image writer works. It asks us for an image. We select the netbook-remix img file and start writing it to the usb stick.

Ok now that it is done put it in the dell mini and boot it on up. We first select the try option to see how it will look and if samba networking is fixed. Up it comes we click on networking and //megatron and //mothra show up immediately. We can't mount mothra shares so we try megatron. No joy here. Networking works as we can get to the internet but not to my local network. On the plus side this is running pretty fast off the usb stick.

Also not sure i like the desktop - it is designed like all the netbook OS with a bunch of icons cluttering up your space. This is supposed to be better? We do have an inspiron 910 img we could try as well as the stock ubuntu 9 cd. Let's try the CD first.

Ok we plug in a usb and boot to the liveCD mode and try to browse the network shares. The machines show up but unable to mount their shares to see them. Internet works but not the local network. So we might as well keep the machine as is and if time permits do some samba troubleshooting. This has always been a weakness of Linux, imho - osx works perfectly well with windows shares and it is a multi-vendor world. I don't like windows but we have to co-exist with it so it should just work.

Sunday, August 2, 2009

VNC on the USB

Remote Access via the USB Stick

Last week while cleaning out the storage device i ran across an old vnc program. I had used this in class some years ago to connect to the Linux server i was running in my office. It got me thinking about adding VNC capabilities to the USB stick.

There is no listed VNC downloadable application at http://portableapps.com/apps but you can add non-installable programs to the environment. For example, I setup winamp for an internet radio on a usb stick demo some terms ago.

So off we go to http://www.tightvnc.com/ to grab the latest version of the viewer which is tightvnc-1.3.10_x86_viewer.zip from which we extract vncviewer.exe

Next we create a file folder called vnc in the /PortableApps folder on the USB stick and copy vncviewer.exe to that folder. From the Portable Apps menu we select Options, Refresh App Icons and the menu item TightVNC Win32 Viewer is added. You can do this for most applications that do not install but you have to create a folder for them else portable apps will not create a menu item.

VNC Server

The next step is to set up the VNC server. Since our portable server is a mac mini running osx server it already has a VNC server, we just have to turn it on. So over to the mac and select System Preferences, Sharing. We place a checkmark in the Screen Sharing box and set a password for the VNC viewer. This is for version 10.5, which has made some changes from the setup used in 10.4 but instructions for 10.4 can be found at http://www.dssw.co.uk/blog/2007/05/14/a-vnc-server-is-included-in-mac-os-x-104/.

Connecting

Backto the USB stick we run VNC viewer and enter the IP address of the osx server.

It makes the connection and the password box is shown. If we had not specified a password in the VNC server setup for osx then any vnc client could connect to and administer the osx server! We enter the password and the mac osx server desktop is displayed. Everything works but of course the screen refreshes are a bit slow as is usual with vnc. The idea behind this is to create a portable server that can be taken to class and used to demonstrate various technologies. The reasons behind this approach are:

- corporate IT is against users running servers from their offices
- if they install a server it is so locked down that students do not learn necessary skills
- most IT depts are windows-centric in a world where windows is rapidly becoming irrelvant

Why mac?

So why is the server running mac osx? Well, their are a number of reasons that make this the best choice for a portable server. Here are the criteria i developed:

- portability: the server must be portable which means light and small
- open source: the server must run common standard open source technologies such as perl, php, apache, ruby, mail, mysql etc.
- GUI: the server must have a gui interface for easy of use in a classroom. Doing lots of typing is a sure way to lose the interest of the students in a class....

So what are the options? The first choice would be a laptop and there are some nice laptops (i own 4) but all have compromises or limitations. My best laptop runs Ubuntu 9 and can be a portable server, in fact it runs a number of useful things as virtualbox vm's (windows, ubuntu server 9 with joomla, mac) but it is too heavy for lugging about. The 11" laptop is not quite light and portable but the battery last for less than 2 hours which makes it rather non-portable for class use. I am toying with the idea of making it into a full ubuntu server. The problem with ubuntu server is that there is no gui. I tried a long time ago (ver 6, 7?) to install the server and then install the desktop but it was a failure. May try again.

One neat possibility is the netbook which is a 2 gig DT atom 1.66 with 64 gig ssd with a battery life of 3.5 hours. This is running the dell netbook version of ubuntu (8). I'm thinking of moving this to the ubuntu netbook version of 9 to fix some issues (samba) that are needed. Right now it has Xampp running but it is a pain to maintain/administer due to it being installed in /opt instead of the user's home directory. This means you have to sudo everything when you want to do stuff - an unecessary annoyance, IMHO. It would be easier if it ran under the user account.

We could use the mac laptop but the consumer laptops cannot run osx server and also use desktop apps like iLife. The solution would be to put osx server on a portable drive and choose to boot from that. I may look at the macbook pro this fall.

Anyway the mac mini is small, runs standard os software with a nice gui on top and does all we want. What's not to like?

time for some lunch