homepage Welcome to WebmasterWorld Guest from 54.166.62.226
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

This 58 message thread spans 2 pages: 58 ( [1] 2 > >     
Putting a new dynamic PHP/MySQL site on a cd-rom
Any technology available to make dynamic access possible?
louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 1:22 pm on Dec 10, 2002 (gmt 0)

I have a dynamic site using PHP/MySQL that I now need to put on a cd-rom. It's basically an informational site, with about 1000 records of info, and several ways to query them. Of course I could hard-code a certain number of queries and query-responses and put a few hundred static .htm pages on the cd to run the queries and responses-to-queries and work it that way, but that would both make for a lot of work, and limit the cross-criteria queries quite a bit.

Any other way to do it without getting into a mega-budget?

 

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 2:06 pm on Dec 10, 2002 (gmt 0)

Just put Apache/PHP and MySQL on the CD-ROM as well. Write a batch file that creates a directory on the hd for temporary files and log files and which starts Apache and MySQL.

This works great for me.

Andreas

louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 4:59 pm on Dec 10, 2002 (gmt 0)

wow, I had no idea that could be done. Do you mean that apache, php and mysql will run direct from a cd without ever having been installed on the machine in question? What would the restrictions be in terms of operating system?

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:03 pm on Dec 10, 2002 (gmt 0)

Apache, PHP and MySQL are available for at least Windows and Linux. Both can be used. So far I have used Windows but I imagine one could make an elegant solution using Knoppix. That way you wouldn´t even have to worry about the OS the box is usually running on.

Andreas

louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:28 pm on Dec 10, 2002 (gmt 0)

Apache, PHP and MySQL are available for at least Windows and Linux.
Yes, of coures - but I had no idea that all would run directly off the cd - do you mean that all you have to do is place apache, php and mysql on a cd and if I place the appropriate batch file as an autorun, all of it will work? cool.
I imagine one could make an elegant solution using Knoppix.
hmm. I just checked out their site - sorry, I'm a bit of a newbie, so it's not very clear to me - as I understand, this is a lightweight os that will run directly off the cd?
andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:33 pm on Dec 10, 2002 (gmt 0)

Knoppix is a GNU/Linux distribution that will run directly off the cd.

See this thread Running Linux from a CD [webmasterworld.com]

and if I place the appropriate batch file as an autorun, all of it will work?
exactly.

Andreas

louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 7:19 pm on Dec 10, 2002 (gmt 0)

Sounds great - thanks, Andreas! :-)
Now I'll just have to dig into how to create that batch file...

trismegisto

10+ Year Member



 
Msg#: 1760 posted 7:30 pm on Dec 11, 2002 (gmt 0)

Just put Apache/PHP and MySQL on the CD-ROM as well… create a directory on the hd for temporary files and log files and which starts Apache and MySQL

hey andreas, any hints about how to write that batch file for linux?

cyclic

10+ Year Member



 
Msg#: 1760 posted 7:45 pm on Dec 11, 2002 (gmt 0)

Great thread - go on Andreas how do you do it?!

louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 8:30 pm on Dec 11, 2002 (gmt 0)

I have been investigating this further, and on a couple other newsgroup discussions, have found statements that the database itself can't be on the cd-rom. Andreas, you say that apache, php and mysql can be on the cd - how about the mysql database files themselves? In my case, this is a display-only database.

I have also found a prog that seems to manage everything :
www.indigostar.com/microweb.htm
(cost = $299)

[edited by: jatar_k at 8:34 pm (utc) on Dec. 11, 2002]
[edit reason] delinked [/edit]

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:00 pm on Dec 12, 2002 (gmt 0)

#!/usr/bin/perl 
#
#-----------------------------------------------------------------------------#
#
# Copyright (c) 2002 Andreas Friedrich. All rights reserved.
#
# This script prepares the system to run Apache, PHP and MySQL
# directly from CD-ROM.
#
# It relies on the correct setting of the TEMP and windir environment
# variables.
#
#-----------------------------------------------------------------------------#
#
use Cwd;
use File::Copy;
use File::Path;
#
use strict;
#
my ($cwd) = cwd =~ /^([a-zA-Z]:)/;
my $tmp = $ENV{TEMP};
my $win = $ENV{windir};
#
print $tmp, "\n", $cwd;
#
mkpath "$tmp/Apache";
#
open 'IN', "<$cwd/Apache/conf/httpd.conf"
or die "Couldn´t open $cwd/Apache/conf/httpd.conf: $!\n";
open 'OUT', ">$tmp/Apache/httpd.conf"
or die "Couldn´t open $tmp/httpd.conf: $!\n";
#
while (<IN>) {
s!%%DRIVE%%!$cwd!g;
s!%%LOGS%%!$tmp/Apache!g;
print OUT;
}
#
close 'IN';
close 'OUT';
#
copy "$cwd/php-4.2.3-Win32/php4ts.dll", "$win/php4ts.dll"
or die "Couldn´t copy $cwd/php-4.2.3-Win32/php4ts.dll to $win/php4ts.dll: $!\n";
#
system "start MySQL/bin/mysqld-opt.exe --skip-innodb";
system "start Apache/Apache.exe -f $tmp/Apache/httpd.conf";
system "start $cwd/start.html";

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:02 pm on Dec 12, 2002 (gmt 0)

autorun.inf
[autorun] 
OPEN=start_.bat

start.bat

perl2\bin\perl.exe start.pl

start.html

<html> 
<head>
<meta http-equiv="Refresh" content="0;url=http://localhost:8181/">
</head>
<body>
<a href="http://localhost:8181/">Click here</a>
</body>
</html>

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:10 pm on Dec 12, 2002 (gmt 0)

#ServerRoot: The top of the directory tree under which the server's 
# configuration, error, and log files are kept.
#
ServerRoot "%%DRIVE%%/Apache"

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
#
PidFile %%LOGS%%/httpd.pid

#
# ScoreBoardFile: File used to store internal server process information.
# Not all architectures require this. But if yours does (you'll know because
# this file will be created when you run Apache) then you *must* ensure that
# no two invocations of Apache share the same scoreboard file.
#
ScoreBoardFile %%LOGS%%/apache_runtime_status

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
#Listen 3000
Listen 8181

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Please read the file README.DSO in the Apache 1.3 distribution for more
# details about the DSO mechanism and run `apache -l' for the list of already
# built-in (statically linked and thus always available) modules in your Apache
# binary.
#
# Note: The order in which modules are loaded is important. Don't change
# the order below without expert advice.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule status_module modules/mod_status.so
#LoadModule info_module modules/mod_info.so
#LoadModule speling_module modules/mod_speling.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule anon_auth_module modules/mod_auth_anon.so
#LoadModule dbm_auth_module modules/mod_auth_dbm.so
#LoadModule digest_auth_module modules/mod_auth_digest.so
#LoadModule digest_module modules/mod_digest.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule php4_module %%DRIVE%%/php-4.2.3-Win32/sapi/php4apache.dll

#
# Reconstruction of the complete module list from all available modules
# (static and shared ones) to achieve correct module execution order.
#
# The modules listed below, without a corresponding LoadModule directive,
# are static bound into the standard Apache binary distribution for Windows.
#
# Note: The order in which modules are loaded is important. Don't change
# the order below without expert advice.
#
# [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE, UPDATE THIS TOO!]
ClearModuleList
#AddModule mod_vhost_alias.c
AddModule mod_env.c
AddModule mod_log_config.c
#AddModule mod_mime_magic.c
AddModule mod_mime.c
AddModule mod_negotiation.c
#AddModule mod_status.c
#AddModule mod_info.c
AddModule mod_include.c
AddModule mod_autoindex.c
AddModule mod_dir.c
AddModule mod_isapi.c
AddModule mod_cgi.c
AddModule mod_asis.c
AddModule mod_imap.c
AddModule mod_actions.c
#AddModule mod_speling.c
AddModule mod_userdir.c
AddModule mod_alias.c
AddModule mod_rewrite.c
AddModule mod_access.c
AddModule mod_auth.c
#AddModule mod_auth_anon.c
#AddModule mod_auth_dbm.c
#AddModule mod_auth_digest.c
#AddModule mod_digest.c
#AddModule mod_proxy.c
#AddModule mod_cern_meta.c
#AddModule mod_expires.c
#AddModule mod_headers.c
#AddModule mod_usertrack.c
#AddModule mod_unique_id.c
AddModule mod_so.c
AddModule mod_setenvif.c

AddModule mod_php4.c
AddType application/x-httpd-php .php

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "%%DRIVE%%/htdocs"

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "%%DRIVE%%/htdocs">

#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog %%LOGS%%/error.log

#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here. Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
CustomLog %%LOGS%%/access.log common

#
# If you would like to have agent and referer logfiles, uncomment the
# following directives.
#
#CustomLog %%LOGS%%/referer.log referer
#CustomLog %%LOGS%%/agent.log agent

#
# If you prefer a single logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
#CustomLog %%LOGS%%/access.log combined

#
# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
<IfModule mod_alias.c>

#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL. So "/icons" isn't aliased in this
# example, only "/icons/". If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
Alias /icons/ "%%DRIVE%%/Apache/icons/"

<Directory "%%DRIVE%%/Apache/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "%%DRIVE%%/Apache/cgi-bin/"

#
# "F:/Apache Group/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "%%DRIVE%%/Apache/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

</IfModule>
# End of aliases.


andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:18 pm on Dec 12, 2002 (gmt 0)

In about half an hour ou may download a zip file containing Apache, PHP, MySQL and ActiveState Perl and the various scripts from here [ecotur.de]. It is uploading right now.

Please be kind on my server and me. I did not test this extensively. It works on WinNT but that´s all I checked.

Feel free to post comments, questions or improvements here.

Andreas

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:22 pm on Dec 12, 2002 (gmt 0)

A linux version may follow soon ;)

Andreas

louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 5:35 pm on Dec 12, 2002 (gmt 0)

VERY cool, Andreas - I'm flat out of time right now, but I'll do some testing over the weekend, on Win2K and Win98.

Thanks! :-)

trismegisto

10+ Year Member



 
Msg#: 1760 posted 1:42 pm on Dec 13, 2002 (gmt 0)

hey andreas, first things first: well done! what you did doesn’t see easy.

i have a question. having knoppix, apache, php & mysql on the cd makes you able to run a web server on any machine on the fly, right? my question is: if you put a dynamic site on a cd, do you have to build the database before burning it into the cd? does that mean that you couldn’t be able to add new records to your cd dynamic website database? is there a way to run the “mysql engine” from the cd and write the mysql database in the computer? (mysql engine and mysql databases would be on different disks?)… well, actually those are questions, not only one :)

the possibility of running a web server from a cd makes my shudder in excitement! it’s so cool!

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 1:37 am on Dec 14, 2002 (gmt 0)

Thanks trismegisto.

if you put a dynamic site on a cd, do you have to build the database before burning it into the cd? does that mean that you couldn’t be able to add new records to your cd dynamic website database?

Yes and yes if you are talking about a CD-R.

is there a way to run the “mysql engine” from the cd and write the mysql database in the computer?

Yes. You would need to use my.ini or my.cnf to set the datadir=s:/MySQL/data directive to the directory containing the databases. You could either burn my.ini/cnf on CD in which case the datadir path would be hard coded or use the same approach I used for the httpd.conf file.

Andreas

dhdweb

10+ Year Member



 
Msg#: 1760 posted 1:02 pm on Dec 14, 2002 (gmt 0)

Andreas,

You should write a book and call it "AndreaScript" :)

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 4:21 pm on Dec 14, 2002 (gmt 0)

Thanks for the suggestion, dhdweb.

Writing a book might be fun but calling it Andreascript might be a bit conceited. ;)

If I ever were to try and challenge Pe[a]rl by writing my own sripting language I would call it A[a]ron ;)

BTW just for the fun of it I implemented a very rudimentary programming language in PHP. I know that this is not really the way to go but it was fun anyway.

Andreas

jordie

10+ Year Member



 
Msg#: 1760 posted 12:31 pm on Dec 16, 2002 (gmt 0)

Hey,
Andreas your link doesn't work anymore, i get a forbidden error. I would really like to get this from you, if you could put it up on your site, or if you email me <snip> and I will let you upload it to my site so I can download it or something.

Thanks.

[edited by: jatar_k at 4:35 pm (utc) on Dec. 16, 2002]
[edit reason] email in profile please [/edit]

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 1:49 pm on Dec 16, 2002 (gmt 0)

Welcome to WebmasterWorld [webmasterworld.com] jordie.

The link is working fine. You just can´t use GetRight. Use your browser instead.

Let me know if this works for you. So far there have been quite a few downloads but no feedback :o

Andreas

louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 10:41 pm on Dec 17, 2002 (gmt 0)

ok, I'm a *relative* mysql newbie now, so please be kind. Andraes, I have installed your complete directory structure on a cd-rom, and well, it's not running. I assumed that there was nothing specific to set to get it running on my own machine, right? First of all, the autorun batch file isn't opening up my browser, then if I manually open start.html, first it doesn't find localhost:8181 and then when I reload, I get :
Verbindung zum Datenbankserver fehlgeschlagen.Fehler: Vebindung zum MySQL Datenbankserver localhost fehlgeschlagen.
Warning: Access denied for user: 'ODBC@localhost' (Using password: NO) in e:\htdocs\index.php on line 21

help?

<added>a couple of things that might be relevant: my cd-rom drive is on E: and I already have a mysql setup on my hard-drive. When I fire up the cd, without starting anything up on my hard drive, if I then run the mysql monitor from the cd-rom, it "finds" the databases on my hard-drive.</added>

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 11:07 pm on Dec 17, 2002 (gmt 0)

I assumed that there was nothing specific to set to get it running on my own machine

Me too ;)

Do other CDs that use the autostart feature start ok?

Did you run the start_.bat batch file prior to opening start.html?

Is there another MySQL server running on your box?

I´m kind of puzzled by this: 'ODBC@localhost' (Using password: NO)

Did you change index.php prior to burning the whole thing on CD.

What Windows version do you use?

autorun batch file isn't opening up my browser

Does it run start_.bat?

Does start e:\start.htm work?

Andreas

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 11:12 pm on Dec 17, 2002 (gmt 0)

I just read what you added to your post.

If there is another mysql server already running at the standard port number then the new one will not start.

While I made Apache use a non-standard port I assumed that is was ok to use the standard one for MySQL. This was a bit foolish as I do realize.

Just give me an hour and I´ll make a new start.pl available ;)

Please be so kind as to answer my questions from the previous post if they are not yet answered.

Andreas

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 11:45 pm on Dec 17, 2002 (gmt 0)

index.php
Change line three to read:
$host = "localhost:8182";

start.pl
Change line 46 to read:
system "start MySQL/bin/mysqld-opt.exe --skip-innodb --port=8182";

Keep in mind that the MySQL server is now listening on port 8182. You need to specify that portnumber along with the hostname when you connect to the server.

Andreas

louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 11:51 pm on Dec 17, 2002 (gmt 0)

> Do other CDs that use the autostart feature start ok?
yes.
> Did you run the start_.bat batch file prior to opening start.html?
yes, the batch file runs via the autorun
>Is there another MySQL server running on your box?
yes, I have easyphp and that seems to install apache and mysql at boot.
>Did you change index.php prior to burning the whole thing on CD.
no
>What Windows version do you use?
win2000
> Does it run start_.bat?
yes, the perl script runs.

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 11:51 pm on Dec 17, 2002 (gmt 0)

You may also download both files from here [ecotur.de].

Unzip start.zip and put both files in their respective directory.

index.php contains English error messages this time ;)

Andreas

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 11:54 pm on Dec 17, 2002 (gmt 0)

That sounds good louponne. If you download the fixes mysql should work ok.

Does start e:\start.htm work?

Andreas

louponne

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1760 posted 11:55 pm on Dec 17, 2002 (gmt 0)

Thanks but too late - I've already fired up Nero! Results pending....

<added> Does start e:\start.htm work?
Yes, it's when it jumps to htdocs/index.php that I get the error

This 58 message thread spans 2 pages: 58 ( [1] 2 > >
Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved