summaryrefslogtreecommitdiff
path: root/docs/manual/mod/mod_example.html
blob: f582dd45d25641da922a64ffe563b19aa1e79317 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
 <HEAD>
  <TITLE>Apache module mod_example</TITLE>
 </HEAD>
 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
 <BODY
  BGCOLOR="#FFFFFF"
  TEXT="#000000"
  LINK="#0000FF"
  VLINK="#000080"
  ALINK="#FF0000"
 >
  <!--#include virtual="header.html" -->
  <H1 ALIGN="CENTER">Module mod_example</H1>
  <P>
  This module is contained in the <CODE>modules/mod_example.c</CODE> file, and
  <STRONG>is not</STRONG> compiled in by default.  It illustrates many of
  the aspects of the
  <A
   HREF="../misc/API.html"
   REL="Help"
  >Apache 1.2 API</A>
  and, when used, demonstrates the manner in which module callbacks are
  triggered by the server.
  </P>
  <H2>Summary</H2>
  <P>
  The files in the <CODE>src/modules/example directory</CODE> under the
  Apache distribution directory tree are provided as an example to those
  that wish to write modules that use the Apache API.
  </P>
  <P>
  The main file is <CODE>mod_example.c</CODE>, which illustrates all
  the different callback mechanisms and call syntaxes.  By no means does
  an add-on module need to include routines for all of the callbacks -
  quite the contrary!
  </P>
  <P>
  The example module is an actual working module.  If you link it into
  your server, enable the "example-handler" handler for a location, and
  then browse to that location, you will see a display of
  some of the tracing the example module did as the various callbacks
  were made.
  </P>
  <P>
  To include the example module in your server, follow the steps below:
  </P>
  <OL>
   <LI>Uncomment the "AddModule modules/example/mod_example" line near 
    the bottom of
    the <CODE>src/Configuration</CODE> file.  If there isn't one, add
    it; it should look like this:
    <PRE>
     AddModule modules/example/mod_example.o
    </PRE>
   </LI>
   <LI>Run the <CODE>src/Configure</CODE> script
    ("<SAMP>cd&nbsp;src;&nbsp;./Configure</SAMP>").  This will
    build the Makefile for the server itself, and update the
    <CODE>src/modules/Makefile</CODE> for any additional modules you
    have requested from beneath that subdirectory.
   </LI>
   <LI>Make the server (run "<SAMP>make</SAMP>" in the <CODE>src</CODE>
    directory).
   </LI>
  </OL>
  <P>
  To add another module of your own:
  </P>
  <OL TYPE="A">
   <LI><SAMP>mkdir src/modules/<EM>mymodule</EM></SAMP>
   </LI>
   <LI><SAMP>cp src/modules/example/* src/modules/<EM>mymodule</EM></SAMP>
   </LI>
   <LI>Modify the files in the new directory.
   </LI>
   <LI>Follow steps [1] through [3] above, with appropriate changes.
   </LI>
  </OL>
  <H3>
   Using the <SAMP>mod_example</SAMP> Module
  </H3>
  <P>
  To activate the example module, include a block similar to the
  following in your <SAMP>srm.conf</SAMP> file:
  </P>
  <PRE>
   &lt;Location /example-info&gt;
       SetHandler example-handler
   &lt;/Location&gt;
  </PRE>
  <P>
  As an alternative, you can put the following into a
  <A
   HREF="core.html#accessfilename"
  ><SAMP>.htaccess</SAMP></A>
  file and then request the file &quot;test.example&quot; from that
  location:
  </P>
  <PRE>
   AddHandler example-handler .example
  </PRE>
  <P>
  After reloading/restarting your server, you should be able to browse
  to this location and see the brief display mentioned earlier.
  </P>
  <H2>Directives</H2>
  <P>
  <UL>
   <LI><A HREF="#example">Example</A>
   </LI>
  </UL>
  </P>
  <HR>
  <H2><A NAME="example">
   Example
  </A></H2>
  <P>
  <A
   HREF="directive-dict.html#Syntax"
   REL="Help" 
  ><STRONG>Syntax:</STRONG></A> Example
  <BR>
  <A
   HREF="directive-dict.html#Default"
   REL="Help" 
  ><STRONG>Default:</STRONG></A> None
  <BR>
  <A
   HREF="directive-dict.html#Context"
   REL="Help" 
  ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
  .htaccess
  <BR>
  <A
   HREF="directive-dict.html#Override"
   REL="Help" 
  ><STRONG>Override:</STRONG></A> Options
  <BR>
  <A
   HREF="directive-dict.html#Status"
   REL="Help" 
  ><STRONG>Status:</STRONG></A> Extension
  <BR>
  <A
   HREF="directive-dict.html#Module"
   REL="Help" 
  ><STRONG>Module:</STRONG></A> mod_example
  <BR>
  <A
   HREF="directive-dict.html#Compatibility"
   REL="Help" 
  ><STRONG>Compatibility:</STRONG></A> <SAMP>Example</SAMP> is only
   available in Apache 1.2 and later.
  </P>
  <P>
  The <SAMP>Example</SAMP> directive activates the example module's
  content handler 
  for a particular location or file type.  It takes no arguments.  If
  you browse to an URL to which the example content-handler applies, you
  will get a display of the routines within the module and how and in
  what order they were called to service the document request.
  </P>
  <!--#include virtual="footer.html" -->
 </BODY>
</HTML>