Configuring for the Apache Server
There are three possibilities to choose from when configuring your
Apache server to work with Meta-HTML files:
- You can run every document on your
server through the Meta-HTML CGI Engine. While there is
nothing horribly wrong with this, it is essentially equivalent to
running the Meta-HTML server itself, so we do not highly
recommend it.
- You can run only Meta-HTML
documents through the Meta-HTML CGI Engine, foregoing the
ability to use statefull sessions with non-cookie capable
browsers. If you never use statefull sessions, or, if you only
have cookie-capable clients connecting to your server (e.g.,
Netscape, MSIE), this solution is completely reasonable, and
totally painless.
- You can run only Meta-HTML
documents through the Meta-HTML CGI Engine, handling the
case of non-cookie capable browsers co-existing with statefull
sessions. This is our recommended configuration.
Step 1: Install the Engine:
In order for the Engine to operate under Apache, you must place it
in your cgi-bin directory, and make it executable. For
example, if your srm.conf file contained:
ScriptAlias /cgi-bin/ /www/htdocs/cgi-bin/
then you would copy the Engine and its config file to that directory:
user@host$ cp engine/engine /www/htdocs/cgi-bin/nph-engine
user@host$ cp engine/engine.conf /www/htdocs/cgi-bin/
Step 2: Edit the engine.conf file:
Now edit the engine.conf file in
/www/htdocs/cgi-bin, simply by reading the comments.
For most installations, you won't actually need to change any of the
parameters defined within -- the saavy site administrator may wish
to add special behaviour, or to modify the existing behaviour.
Step 3: Edit the Apache srm.conf file:
Now edit the srm.conf for your Apache server.
There are two possible edits:
- Running Every Document Through the Engine
Add the following line before all of your other ScriptAlias
lines:
ScriptAlias / /cgi-bin/nph-engine
- Running Only Meta-HTML Documents Through the Engine
Add the following lines to the srm.conf file, before
all other ScriptAlias lines:
AddType metahtml/interpreted .mhtml
Action metahtml/interpreted /cgi-bin/nph-engine
Step 4: Compiling Apache 1.x With the Meta-HTML "mini-module":
If you want to make sure that non-cookie capable browsers can have
statefull sessions, you will need to recompile your 1.x server
with the Meta-HTML mini-module installed. Here is how to do that:
Place the following line in src/Configuration (in
your Apache 1.x source tree)
Module mhtml_module mod_mhtml.o
Copy the mod_mhtml.c file to the src
directory of your Apache 1.x source tree.
Reconfigure the compilation of your server by typing
./Configure from the src directory of
your Apache 1.x source tree.
Recompile the Apache server by typing make, and then
copy the httpd file to whereever you have installed
the previous version of the Apache server.
That's it!
Congratulations! You have configured the Meta-HTML Engine to work
with your Apache server!
So that you can see exactly what the mini-module does, I have
included the source code below:
/* mod_mhtml.c: -*- C -*- Apache mini-module code for Meta-HTML. */
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
/* If the URI starts with a string of digits, leave them there, but
make the filename be everything after it. */
static int
translate_filename (struct request_rec *req)
{
register int i;
int result = DECLINED;
if ((req->uri != (char *)NULL) &&
((req->uri[0] == '/') && (isdigit (req->uri[1]))))
{
for (i = 1; isdigit (req->uri[i]); i++);
/* If the URI contains a cookie, then gobble it, stuff it into
req->subprocess_env, and move along. */
if (req->uri[i] == '\0' || req->uri[i] == '/')
{
register int j;
char *value = (char *)palloc (req->pool, 1 + i);
table *page_env = req->subprocess_env;
strncpy (value, req->uri + 1, i - 1);
value[i - 1] = '\0';
for (j = 0; req->uri[i] != '\0'; j++, i++)
req->uri[j] = req->uri[i];
req->uri[j] = '\0';
/* Now stuff the value into a meaningful environment variable. */
table_add (req->subprocess_env, "METAHTML_URL_COOKIE", value);
}
}
return (result);
}
module mhtml_module =
{
STANDARD_MODULE_STUFF,
NULL, /* initializer */
NULL, /* dir config creater */
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
NULL, /* command table */
NULL, /* handlers */
translate_filename, /* filename translation */
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
NULL, /* type_checker */
NULL, /* fixups */
NULL /* logger */
};

The
META-HTML
Reference Manual V2.0
Copyright © 1995, 1998,
Brian J. Fox
Found a bug? Send mail to
bug-manual@metahtml.org
|