]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_example.html.en
a few new translations and up-to-date patches
[apache] / docs / manual / mod / mod_example.html.en
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
7       -->
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>
13 <body>
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="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
19 <div id="path">
20 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="../">Version 2.1</a> &gt; <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_example</h1>
23 <div class="toplang">
24 <p><span>Available Languages: </span><a href="../en/mod/mod_example.html" title="English">&nbsp;en&nbsp;</a> |
25 <a href="../ko/mod/mod_example.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
26 </div>
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>
31 <h3>Summary</h3>
32
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
36     API.</p>
37
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>
42
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>
48 </div>
49 <div id="quickview"><h3 class="directives">Directives</h3>
50 <ul id="toc">
51 <li><img alt="" src="../images/down.gif" /> <a href="#example">Example</a></li>
52 </ul>
53 <h3>Topics</h3>
54 <ul id="topics">
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>
57 </ul></div>
58 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
59 <div class="section">
60 <h2><a name="compiling" id="compiling">Compiling the example module</a></h2>
61
62     <p>To include the example module in your server, follow the
63     steps below:</p>
64
65     <ol>
66       <li>
67         Run <code>configure</code> with <code>--enable-example</code>
68         option.</li>
69
70       <li>Make the server (run "<code>make</code>").</li>
71     </ol>
72
73     <p>To add another module of your own:</p>
74
75     <ol class="up-A">
76       <li><code>cp modules/experimental/mod_example.c
77       modules/new_module/<em>mod_myexample.c</em></code></li>
78
79       <li>Modify the file.</li>
80
81       <li>Create <code>modules/new_module/config.m4</code>.
82         <ol>
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
92             examples.</li>
93           <li>Add <code>APACHE_MODPATH_FINISH</code>.</li>
94         </ol>
95       </li>
96
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>
101
102       <li>Run ./buildconf from the top-level directory.</li>
103
104       <li>Build the server with --enable-myexample</li>
105
106     </ol>
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>
110
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    &lt;Location /example-info&gt;<br />
115        SetHandler example-handler<br />
116    &lt;/Location&gt;
117 </code></p></div>
118
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
123 </code></p></div>
124
125     <p>After reloading/restarting your server, you should be able
126     to browse to this location and see the brief display mentioned
127     earlier.</p>
128 </div>
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
133 API</td></tr>
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>
138 </table>
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>
147
148 </div>
149 </div>
150 <div class="bottomlang">
151 <p><span>Available Languages: </span><a href="../en/mod/mod_example.html" title="English">&nbsp;en&nbsp;</a> |
152 <a href="../ko/mod/mod_example.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</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>
156 </body></html>