Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Windows - running Apache and MySQL from a CD

Q - I'm writing a web based application (using PHP and MySQL) and I've just been told that I also need to produce a stand alone demo version to run on PCs running windows. What shall I do?

A - Configure an Apache server, PHP and MySQL to run from a CD, using port numbers that aren't normally used. Add a batch file to install the few directories that need to be writable on the user's PC, and to kick off the services / daemons. Your demo version will then be useable in just the same way as the web based application - it will even be accessible on your intranet if the demo PC is connected! Since all the components of the system are Open Source, you shouldn't have licensing issues if you're giving away your demo version - but it might be as well to check with the MySQL folks in particular if you're going to be selling it to make money - their general motto is "If you're distributing it for free, we're free. If you're charging, then we'll charge you".

A grand theory, but does it work in practice? Yes, we've done it!

In detail:


1. Create a folder under the top level of your C: drive (in our example, we've called it c:\dcserver)

2. Download the distributions that you want to install on your server - we've put ours into a subdirectory of dcserver to that the full originals will be distributed onwards with the CD, making open source license adherence easier and ensuring that we have all the original tools available for tailoring later.


3. Install the web server to a subdirectory of dcserver (we've chosen to call ours Apache)

4. Install the PHP distribution to a subdirectory of dcserver (we've called ours PHP)

5. Copy the PHP .dll files and the php.ini file from the php directory to the apache directory as described in the PHP installation instructions

6. Create a subdirectory for read/write information testing on the c: drive - we've called ours c:\dcdata

7. Modify the Apache configuration file, removing drive-specific references (since you don't know what drive letter will be used when you run the CD) and pointing error log and other output areas at the c:\dcdata area. Here's a log of the changes we made for this purpose using the above releases of the software. Other mods are made here too - we've also changed the server from port 80 to port 8000 to avoid conflict with any other web server running on the host system, and we've added in the extra stuff to call up the PHP.

< ServerRoot "C:/dcserver/apache/Apache"
> ServerRoot "/dcserver/apache/Apache"
< PidFile logs/httpd.pid
> PidFile c:/dcdata/httpd.pid
< ScoreBoardFile logs/apache_runtime_status
> ScoreBoardFile c:/dcdata/apache_runtime_status
> Listen 8000
< Port 80
> Port 8000
< DocumentRoot "C:/dcserver/apache/Apache/htdocs"
> DocumentRoot "/dcserver/apache/Apache/htdocs"
< <Directory "C:/dcserver/apache/Apache/htdocs">
> <Directory "/dcserver/apache/Apache/htdocs">
< UserDir "C:/dcserver/apache/Apache/users/"
> UserDir "/dcserver/apache/Apache/users/"
< ErrorLog logs/error.log
> ErrorLog c:/dcdata/httpderror.log
< CustomLog logs/access.log common
> # CustomLog logs/access.log common
< Alias /icons/ "C:/dcserver/apache/Apache/icons/"
> Alias /icons/ "/dcserver/apache/Apache/icons/"
< <Directory "C:/dcserver/apache/Apache/icons">
> <Directory "/dcserver/apache/Apache/icons">
< Alias /manual/ "C:/dcserver/apache/Apache/htdocs/manual/"
> Alias /manual/ "/dcserver/apache/Apache/htdocs/manual/"
< <Directory "C:/dcserver/apache/Apache/htdocs/manual">
> <Directory "/dcserver/apache/Apache/htdocs/manual">
< ScriptAlias /cgi-bin/ "C:/dcserver/apache/Apache/cgi-bin/"
> ScriptAlias /cgi-bin/ "/dcserver/apache/Apache/cgi-bin/"
< <Directory "C:/dcserver/apache/Apache/cgi-bin">
> <Directory "/dcserver/apache/Apache/cgi-bin">
> ####################### Extra Stuff!!
> AddType application/x-httpd-php .php .php4
> LoadModule php4_module "/dcserver/apache/Apache/bin/php4apache.dll"
> SetEnv PHPRC /dcserver/apache/Apache/bin

8. Start the test server by running the apache.exe file that's at the top of the Apache tree; you should get a message that Apache and PHP have started


9. Point your browser at
and you should see a "your Apache server has been successfully installed" page.

10. place the following in a file called first.html in the htdocs directory
 <head><title>Stand Alone Apache Test</title></head>
 <body><h1>Test</h1>Server operational</body>
and point your browser at

11. place the following in a file called second.php in the htdocs directory
 <h1>Stand Alone CD Server verification</h1>
 <?php phpinfo(); ?>
and point your browser at


12. Unpack and install MySQL in a subdirectory of c:\dcserver (i.e. run the setup.exe script)

13. Start the MySQL server on port 3307 using
 mysql\bin\mysqld --port=3307 --basedir=/dcserver/mysql --datadir=/dcserver/mysql/data/

14. log in to MySQL and set up a test user account - let's call it user "trainee" with password "abc123". Also at this stage you should set the root password for the SQL server.

15. Create a test table in mysql - for example use the mysql client program to
 use test;
 create table example (id int primary key not numm auto_increment,
   info text);
 insert into example (info) values ("The sky is blue");
 insert into example (info) values ("The grass is green");

16. Test the MySQL in association with the web server and PHP by creating the following file in the htdocs area of apache - called third.php:
 <h1>MySQL test</h1>
 mysql_connect("localhost:3307","trainee","abc123") ;
 $rid = mysql_query("select * from example");
 while ($igot = mysql_fetch_assoc($rid)) {
         echo $igot[info];
         echo "<br>";
and point your browser at:

At this point you should see a complete PHP page showing the contents of the SQL database. However, the database is running from the dcserver directory which is read/write and this won't work if you try to cut it onto a CD and run from the CD.

The following stages show you how to add batch files onto your CD to copy vital files into the dcdata area when you run from CD on a target machine. You should try these out for testing at this stage, but you'll need to come back and add your application itself into the htdocs directory and into your SQL database and cut production CDs later.


17. Add a file called appstart.html to the htdocs directory to represent the portal to your application
 <head><title>Welcome to the Super Application (CD version)</title></head>
 This is where the fun stuff goes<br>
 For support staff<br>
 <a href=second.php>PHP test</a><br>
 <a href=third.php>PHP and SQL test</a><br>
 If these tests fail, you have server problems<br>

18. Add the file README.html into the \dcserver directory as follows:
 This is the readme file for starting your CD based application....

 To run the web server and Digital Class application from this folder:

 a) Doubleclick on startsql.bat
 b) Doubleclick on startweb.bat
 c) Point a browser at

 Failure to follow these instructions may lead to the software failing
 to work.


 Link <a href=http://localhost:8000/appstart.html>HERE!</a> to Digital class

19. Add a file startsql.bat to the \dcserver directory as follows:
 echo "Starting SQL server. Please ensure web server also started"
 if not exist c:\dcdata mkdir c:\dcdata
 if not exist c:\dcdata\ibdata1 xcopy \dcserver\mysql\data\*.* c:\dcdata /Q/S
 mysql\bin\mysqld --port=3307 --basedir=/dcserver/mysql --datadir=c:/dcdata --read-only

20. Add a file startweb.sql to the \dcserver directory as follows:
 echo off
 echo "Starting web server. Please ensure SQL server also started"
 if not exist c:\dcdata mkdir c:\dcdata
 echo .
 echo .
 echo .
 echo After Web server start message, please ensure SQL server is started
 echo .
 echo .
 echo .

21. Ensure that the web and SQL servers are shut down (a reboot is not a bad idea!)

22. Cut a test CD.


a. Insert the CD into the CD drive on the target computer; a window showing its contents will pop up.

b. Double click on the "startsql" icon

c. Double click on the "startweb" icon

d. Double click on the README.html icon and a browser window will start up. You can follow the links from that page to test your installation.


a. Establish the name or IP address of the machine on which the CD is running.

b. Point a browser on your second test machine at
(replace the IP address in this example as appropriate, but leave the 8000 port number)

Some notes:

i) This is an example setup that you're welcome to use as guidance
- it works for us but you may find different circumstance and you
may wish to modify the procedure. No responsibility can be taken by the author of these notes for any errors or shortcomings, nor the consequences thereof.

ii) The data in the SQL database is left on the hard disc from one run to the next and the sample batch files do NOT overwrite it. You may wish to modify this behaviour for security reasons, or if you want a fresh new start each time.

iii) These notes are written by Graham Ellis of Well House Consultants (graham@wellho.net) and are subject to the copyright statement (c) 2004 on our web site. Please visit our web site (http://www.wellho.net) for details of our training courses which include PHP Programming. MySQL, and Apache configuration and deployment

See also Sourcing, configuring and installing Apache httpd

Please note that articles in this section of our web site were current and correct to the best of our ability when published, but by the nature of our business may go out of date quite quickly. The quoting of a price, contract term or any other information in this area of our website is NOT an offer to supply now on those terms - please check back via our main web site

Related Material

Web Application Deployment - Apache httpd - Sourcing, Installation, Testing
  [523] - ()
  [526] - ()
  [550] - ()
  [660] - ()
  [907] - ()
  [982] - ()
  [1095] - ()
  [1292] - ()
  [1449] - ()
  [1455] - ()
  [1707] - ()
  [1731] - ()
  [1768] - ()
  [1945] - ()
  [2080] - ()
  [2096] - ()
  [2184] - ()
  [2520] - ()
  [3426] - ()
  [4437] - ()

Web Application Deployment - Further httpd Configuration
  [345] - ()
  [466] - ()
  [526] - ()
  [550] - ()
  [631] - ()
  [649] - ()
  [662] - ()
  [755] - ()
  [853] - ()
  [934] - ()
  [1009] - ()
  [1080] - ()
  [1121] - ()
  [1207] - ()
  [1351] - ()
  [1355] - ()
  [1377] - ()
  [1381] - ()
  [1551] - ()
  [1554] - ()
  [1564] - ()
  [1566] - ()
  [1619] - ()
  [1636] - ()
  [1707] - ()
  [1762] - ()
  [1767] - ()
  [1778] - ()
  [1939] - ()
  [1954] - ()
  [1955] - ()
  [1974] - ()
  [2060] - ()
  [2272] - ()
  [2478] - ()
  [2900] - ()
  [3133] - ()
  [3449] - ()
  [3635] - ()
  [3862] - ()
  [3955] - ()
  [4001] - ()
  [4307] - ()

Sourcing, Running and Configuring MySQL
  [192] - ()
  [334] - ()
  [489] - ()
  [515] - ()
  [535] - ()
  [591] - ()
  [907] - ()
  [1095] - ()
  [1123] - ()
  [1131] - ()
  [1689] - ()
  [1731] - ()
  [1771] - ()
  [1935] - ()
  [2085] - ()
  [2209] - ()
  [2426] - ()
  [2444] - ()
  [2445] - ()
  [2458] - ()
  [4390] - ()
  [4406] - ()
  [4487] - ()

resource index - Deployment
Solutions centre home page

You'll find shorter technical items at The Horse's Mouth and delegate's questions answered at the Opentalk forum.

At Well House Consultants, we provide training courses on subjects such as Ruby, Lua, Perl, Python, Linux, C, C++, Tcl/Tk, Tomcat, PHP and MySQL. We're asked (and answer) many questions, and answers to those which are of general interest are published in this area of our site.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/solutions/general- ... -a-cd.html • PAGE BUILT: Wed Mar 28 07:47:11 2012 • BUILD SYSTEM: wizard