1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>mod_example - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
14 <div id="page-header">
15 <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>
16 <p class="apache">Apache HTTP Server Version 2.1</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20 <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>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_example</h1>
24 <p><span>Available Languages: </span><a href="../en/mod/mod_example.html" title="English"> en </a> |
25 <a href="../ko/mod/mod_example.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
27 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Illustrates the Apache module API</td></tr>
28 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
29 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>example_module</td></tr>
30 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_example.c</td></tr></table>
33 <p>Some files in the <code>modules/experimental</code> directory
34 under the Apache distribution directory tree are provided as an
35 example to those that wish to write modules that use the Apache
38 <p>The main file is <code>mod_example.c</code>, which
39 illustrates all the different callback mechanisms and call
40 syntaxes. By no means does an add-on module need to include
41 routines for all of the callbacks - quite the contrary!</p>
43 <p>The example module is an actual working module. If you link
44 it into your server, enable the "example-handler" handler for a
45 location, and then browse to that location, you will see a
46 display of some of the tracing the example module did as the
47 various callbacks were made.</p>
49 <div id="quickview"><h3 class="directives">Directives</h3>
51 <li><img alt="" src="../images/down.gif" /> <a href="#example">Example</a></li>
55 <li><img alt="" src="../images/down.gif" /> <a href="#compiling">Compiling the example module</a></li>
56 <li><img alt="" src="../images/down.gif" /> <a href="#using">Using the <code>mod_example</code> Module</a></li>
58 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
60 <h2><a name="compiling" id="compiling">Compiling the example module</a></h2>
62 <p>To include the example module in your server, follow the
67 Run <code>configure</code> with <code>--enable-example</code>
70 <li>Make the server (run "<code>make</code>").</li>
73 <p>To add another module of your own:</p>
76 <li><code>cp modules/experimental/mod_example.c
77 modules/new_module/<em>mod_myexample.c</em></code></li>
79 <li>Modify the file.</li>
81 <li>Create <code>modules/new_module/config.m4</code>.
83 <li>Add <code>APACHE_MODPATH_INIT(new_module)</code>.</li>
84 <li>Copy APACHE_MODULE line with "example" from
85 <code>modules/experimental/config.m4</code>.</li>
86 <li>Replace the first argument "example" with <em>myexample</em>.</li>
87 <li>Replace the second argument with brief description of your module.
88 It will be used in <code>configure --help</code>.</li>
89 <li>If your module needs additional C compiler flags, linker flags or
90 libraries, add them to CFLAGS, LDFLAGS and LIBS accordingly.
91 See other <code>config.m4</code> files in modules directory for
93 <li>Add <code>APACHE_MODPATH_FINISH</code>.</li>
97 <li>Create <code>module/new_module/Makefile.in</code>.
98 If your module doesn't need special build instructions,
99 all you need to have in that file is
100 <code>include $(top_srcdir)/build/special.mk</code>.</li>
102 <li>Run ./buildconf from the top-level directory.</li>
104 <li>Build the server with --enable-myexample</li>
107 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
108 <div class="section">
109 <h2><a name="using" id="using">Using the <code>mod_example</code> Module</a></h2>
111 <p>To activate the example module, include a block similar to
112 the following in your <code>httpd.conf</code> file:</p>
113 <div class="example"><p><code>
114 <Location /example-info><br />
115 SetHandler example-handler<br />
119 <p>As an alternative, you can put the following into a <a href="core.html#accessfilename"><code>.htaccess</code></a> file
120 and then request the file "test.example" from that location:</p>
121 <div class="example"><p><code>
122 AddHandler example-handler .example
125 <p>After reloading/restarting your server, you should be able
126 to browse to this location and see the brief display mentioned
129 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
130 <div class="directive-section"><h2><a name="Example" id="Example">Example</a> <a name="example" id="example">Directive</a></h2>
131 <table class="directive">
132 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Demonstration directive to illustrate the Apache module
134 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Example</code></td></tr>
135 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
136 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Experimental</td></tr>
137 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_example</td></tr>
139 <p>The <code class="directive">Example</code> directive just sets a demonstration
140 flag which the example module's content handler displays. It
141 takes no arguments. If you browse to an URL to which the
142 example content-handler applies, you will get a display of the
143 routines within the module and how and in what order they were
144 called to service the document request. The effect of this
145 directive one can observe under the point "<code>Example
146 directive declared here: YES/NO</code>".</p>
150 <div class="bottomlang">
151 <p><span>Available Languages: </span><a href="../en/mod/mod_example.html" title="English"> en </a> |
152 <a href="../ko/mod/mod_example.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
153 </div><div id="footer">
154 <p class="apache">Copyright 1999-2004 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
155 <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>