mod_example.html revision eb3e63593a2f2ec26386769e782ce9e77536a779
65fea56f17cd614bc8908264df980a62e1931468vboxsync <!--#include virtual="header.html" -->
65fea56f17cd614bc8908264df980a62e1931468vboxsync This module is contained in the <CODE>modules/mod_example.c</CODE> file, and
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>is not</STRONG> compiled in by default. It illustrates many of
65fea56f17cd614bc8908264df980a62e1931468vboxsync the aspects of the
65fea56f17cd614bc8908264df980a62e1931468vboxsync >Apache 1.2 API</A>
65fea56f17cd614bc8908264df980a62e1931468vboxsync and, when used, demonstrates the manner in which module callbacks are
65fea56f17cd614bc8908264df980a62e1931468vboxsync triggered by the server.
65fea56f17cd614bc8908264df980a62e1931468vboxsync The files in the <CODE>src/modules/example directory</CODE> under the
65fea56f17cd614bc8908264df980a62e1931468vboxsync Apache distribution directory tree are provided as an example to those
65fea56f17cd614bc8908264df980a62e1931468vboxsync that wish to write modules that use the Apache API.
65fea56f17cd614bc8908264df980a62e1931468vboxsync The main file is <CODE>mod_example.c</CODE>, which illustrates all
65fea56f17cd614bc8908264df980a62e1931468vboxsync the different callback mechanisms and call syntaces. By no means does
65fea56f17cd614bc8908264df980a62e1931468vboxsync an add-on module need to include routines for all of the callbacks -
65fea56f17cd614bc8908264df980a62e1931468vboxsync quite the contrary!
65fea56f17cd614bc8908264df980a62e1931468vboxsync The example module is an actual working module. If you link it into
65fea56f17cd614bc8908264df980a62e1931468vboxsync your server, enable the "example-handler" handler for a location, and
65fea56f17cd614bc8908264df980a62e1931468vboxsync then browse to that location, you will see a display of
65fea56f17cd614bc8908264df980a62e1931468vboxsync some of the tracing the example module did as the various callbacks
65fea56f17cd614bc8908264df980a62e1931468vboxsync To include the example module in your server, follow the steps below:
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Uncomment the "Module example_module" line near the bottom of
65fea56f17cd614bc8908264df980a62e1931468vboxsync the <CODE>src/Configuration</CODE> file. If there isn't one, add
65fea56f17cd614bc8908264df980a62e1931468vboxsync it; it should look like this:
65fea56f17cd614bc8908264df980a62e1931468vboxsync Module example_module modules/example/mod_example.o
65fea56f17cd614bc8908264df980a62e1931468vboxsync ("<SAMP>cd src; /Configure</SAMP>"). This will
65fea56f17cd614bc8908264df980a62e1931468vboxsync build the Makefile for the server itself, and update the
65fea56f17cd614bc8908264df980a62e1931468vboxsync <CODE>src/modules/Makefile</CODE> for any additional modules you
65fea56f17cd614bc8908264df980a62e1931468vboxsync have requested from beneath that subdirectory.
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Make the server (run "<SAMP>make</SAMP>" in the <CODE>src</CODE>
65fea56f17cd614bc8908264df980a62e1931468vboxsync directory).
65fea56f17cd614bc8908264df980a62e1931468vboxsync To add another module of your own:
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI><SAMP>mkdir src/modules/<EM>mymodule</EM></SAMP>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI><SAMP>cp src/modules/example/* src/modules/<EM>mymodule</EM></SAMP>
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Modify the files in the new directory.
65fea56f17cd614bc8908264df980a62e1931468vboxsync <LI>Follow steps [1] through [3] above, with appropriate changes.
65fea56f17cd614bc8908264df980a62e1931468vboxsync To activate the example module, include a block similar to the
65fea56f17cd614bc8908264df980a62e1931468vboxsync <Location /example-info>
65fea56f17cd614bc8908264df980a62e1931468vboxsync SetHandler example-handler
65fea56f17cd614bc8908264df980a62e1931468vboxsync </Location>
65fea56f17cd614bc8908264df980a62e1931468vboxsync As an alternative, you can put the following into a
65fea56f17cd614bc8908264df980a62e1931468vboxsync HREF="core.html#accessfilename"
65fea56f17cd614bc8908264df980a62e1931468vboxsync file and then request the file "test.example" from that
65fea56f17cd614bc8908264df980a62e1931468vboxsync AddHandler example-handler .example
65fea56f17cd614bc8908264df980a62e1931468vboxsync After reloading/restarting your server, you should be able to browse
65fea56f17cd614bc8908264df980a62e1931468vboxsync to this location and see the brief display mentioned earlier.
65fea56f17cd614bc8908264df980a62e1931468vboxsync <STRONG>Context:</STRONG> server config, virtual host, directory, .htaccess
65fea56f17cd614bc8908264df980a62e1931468vboxsync The Example directive activates the example module's content handler
65fea56f17cd614bc8908264df980a62e1931468vboxsync for a particular location or file type. It takes no arguments. If
65fea56f17cd614bc8908264df980a62e1931468vboxsync you browse to an URL to which the example content-handler applies, you
65fea56f17cd614bc8908264df980a62e1931468vboxsync will get a display of the routines within the module and how and in
65fea56f17cd614bc8908264df980a62e1931468vboxsync what order they were called to service the document request.
65fea56f17cd614bc8908264df980a62e1931468vboxsync <!--#include virtual="footer.html" -->