mod_example.html.en revision 53bae66d3dc14a667e14a451f7bc65a893dd450f
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
f3091cedd4abeda1026d9117c34e8f625754e8aefielding XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
f3091cedd4abeda1026d9117c34e8f625754e8aefielding This file is generated from xml source: DO NOT EDIT
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<link href="/images/favicon.ico" rel="shortcut icon" /></head>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<p class="apache">Apache HTTP Server Version 2.1</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.1</a> > <a href="./">Modules</a></div>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<div id="preamble"><h1>Apache Module mod_example</h1>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Illustrates the Apache module API</td></tr>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>example_module</td></tr>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_example.c</td></tr></table>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding This document has not been updated
f3091cedd4abeda1026d9117c34e8f625754e8aefielding to take into account changes made in the 2.0 version of the
f3091cedd4abeda1026d9117c34e8f625754e8aefielding Apache HTTP Server. Some of the information may still be
64185f9824e42f21ca7b9ae6c004484215c031a7rbb relevant, but please use it with care.
f3091cedd4abeda1026d9117c34e8f625754e8aefielding <p>The files in the <code>src/modules/example directory</code>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding under the Apache distribution directory tree are provided as an
f3091cedd4abeda1026d9117c34e8f625754e8aefielding example to those that wish to write modules that use the Apache
f3091cedd4abeda1026d9117c34e8f625754e8aefielding <p>The main file is <code>mod_example.c</code>, which
f3091cedd4abeda1026d9117c34e8f625754e8aefielding illustrates all the different callback mechanisms and call
f3091cedd4abeda1026d9117c34e8f625754e8aefielding syntaxes. By no means does an add-on module need to include
f3091cedd4abeda1026d9117c34e8f625754e8aefielding routines for all of the callbacks - quite the contrary!</p>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding <p>The example module is an actual working module. If you link
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding it into your server, enable the "example-handler" handler for a
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding location, and then browse to that location, you will see a
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding display of some of the tracing the example module did as the
f3091cedd4abeda1026d9117c34e8f625754e8aefielding various callbacks were made.</p>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<div id="quickview"><h3 class="directives">Directives</h3>
f3091cedd4abeda1026d9117c34e8f625754e8aefielding<li><img alt="" src="/images/down.gif" /> <a href="#example">Example</a></li>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<li><img alt="" src="/images/down.gif" /> <a href="#compiling">Compiling the example module</a></li>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<li><img alt="" src="/images/down.gif" /> <a href="#using">Using the <code>mod_example</code> Module</a></li>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<h2><a name="compiling" id="compiling">Compiling the example module</a></h2>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>To include the example module in your server, follow the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding steps below:</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding Uncomment the "AddModule modules/example/mod_example" line
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding near the bottom of the <code>src/Configuration</code> file.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding If there isn't one, add it; it should look like this:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ("<code>cd src; /Configure</code>"). This will
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding build the Makefile for the server itself, and update the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <code>src/modules/Makefile</code> for any additional modules
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding you have requested from beneath that subdirectory.</li>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <li><code>mkdir src/modules/<em>mymodule</em></code></li>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <li>Follow steps [1] through [3] above, with appropriate
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding changes.</li>
878c5eb6d9ffca5069d9f140184a133723000f0cwrowe</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<h2><a name="using" id="using">Using the <code>mod_example</code> Module</a></h2>
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb <p>To activate the example module, include a block similar to
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb <Location /example-info><br />
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb SetHandler example-handler<br />
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb </Location>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding <p>As an alternative, you can put the following into a <a href="core.html#accessfilename"><code>.htaccess</code></a> file
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding and then request the file "test.example" from that location:</p>
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb AddHandler example-handler .example
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb <p>After reloading/restarting your server, you should be able
75955a79840ee0134d58addf0dd6733f7f71a99erbb to browse to this location and see the brief display mentioned
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb earlier.</p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
48d7c43629323c8d5ee9f7bd0d194de0a376b391rbb<div class="directive-section"><h2><a name="Example" id="Example">Example</a> <a name="example" id="example">Directive</a></h2>
48d7c43629323c8d5ee9f7bd0d194de0a376b391rbb<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Demonstration directive to illustrate the Apache module
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Example</code></td></tr>
48d7c43629323c8d5ee9f7bd0d194de0a376b391rbb<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
48d7c43629323c8d5ee9f7bd0d194de0a376b391rbb<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
f4a8b04b47f09a21b65646b66b19c9649ff7f03arbb<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_example</td></tr>
48d7c43629323c8d5ee9f7bd0d194de0a376b391rbb <p>The <code class="directive">Example</code> directive just sets a demonstration
cf721750997514b9cbed94bf3672ff6b3e2c2132trawick flag which the example module's content handler displays. It
48d7c43629323c8d5ee9f7bd0d194de0a376b391rbb takes no arguments. If you browse to an URL to which the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding example content-handler applies, you will get a display of the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding routines within the module and how and in what order they were
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding called to service the document request. The effect of this
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding directive one can observe under the point "<code>Example
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>