Demo image Demo image Demo image Demo image Demo image Demo image

XAMPP on a CD

  • Monday, April 16, 2012
  • zana991

  • 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

    0 comments: