]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_so.html
Document the Win32 .so change. Time to rest the brain.
[apache] / docs / manual / mod / mod_so.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>Apache module mod_so</TITLE>
5 </HEAD>
6
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
8 <BODY
9  BGCOLOR="#FFFFFF"
10  TEXT="#000000"
11  LINK="#0000FF"
12  VLINK="#000080"
13  ALINK="#FF0000"
14 >
15 <!--#include virtual="header.html" -->
16 <H1 ALIGN="CENTER">Module mod_so</H1>
17
18 <p>This module provides for loading of executable code and modules into the
19 server at start-up or restart time.</p>
20
21 <P><A
22 HREF="module-dict.html#Status"
23 REL="Help"
24 ><STRONG>Status:</STRONG></A> Base (Windows); Optional (Unix)
25 <BR>
26 <A
27 HREF="module-dict.html#SourceFile"
28 REL="Help"
29 ><STRONG>Source File:</STRONG></A> mod_so.c
30 <BR>
31 <A
32 HREF="module-dict.html#ModuleIdentifier"
33 REL="Help"
34 ><STRONG>Module Identifier:</STRONG></A> so_module
35 <BR>
36 <A
37 HREF="module-dict.html#Compatibility"
38 REL="Help"
39 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later.
40 </P>
41
42
43 <H2>Summary</H2>
44
45 <P>On selected operating systems this module can be used to load modules
46 into Apache at runtime via the <A HREF="../dso.html">Dynamic Shared 
47 Object</A> (DSO) mechanism, rather than requiring a recompilation.
48
49 <P>
50 On Unix, the loaded code typically comes from shared object files
51 (usually with <SAMP>.so</SAMP> extension), on Windows this may either
52 the <SAMP>.so</SAMP> or <SAMP>.dll</SAMP> extension. This module is 
53 only available in Apache 1.3 and up.
54
55 <p>In previous releases, the functionality of this module was provided
56 for Unix by mod_dld, and for Windows by mod_dll. On Windows, mod_dll
57 was used in beta release 1.3b1 through 1.3b5. mod_so combines these
58 two modules into a single module for all operating systems.
59
60 <P><STRONG> Warning: Apache 1.3 modules cannot be directly used with
61    Apache 2.0 - the module must be modified to dynamically load or 
62    compile into Apache 2.0</STRONG>.</P>
63
64 <H2>Directives</H2>
65 <UL>
66 <LI><A HREF="#loadfile">LoadFile</A>
67 <LI><A HREF="#loadmodule">LoadModule</A>
68 </UL>
69
70 <H2><A NAME="creating">Creating Loadable Modules for Windows</A></H2>
71
72 <P><STRONG>Note: the module name format changed for Windows with Apache
73    1.3.15 and 2.0 - the modules are now named as mod_foo.so</STRONG>.
74    While mod_so still loads modules with ApacheModuleFoo.dll names, the
75    new naming convention is preferred; if you are converting your loadable
76    module for 2.0, please fix the name to this 2.0 convention.</P>
77
78 <P>The Apache module API is unchanged between the Unix and Windows
79    versions. Many modules will run on Windows with no or little change
80    from Unix, although others rely on aspects of the Unix architecture
81    which are not present in Windows, and will not work.</P>
82
83 <P>When a module does work, it can be added to the server in one of two
84    ways. As with Unix, it can be compiled into the server. Because Apache
85    for Windows does not have the <CODE>Configure</CODE> program of Apache
86    for Unix, the module's source file must be added to the ApacheCore
87    project file, and its symbols must be added to the
88    <CODE>os\win32\modules.c</CODE> file.</P>
89
90 <P>The second way is to compile the module as a DLL, a shared library
91    that can be loaded into the server at runtime, using the
92    <CODE><A HREF="#loadmodule">LoadModule</A></CODE>
93    directive. These module DLLs can be distributed and run on any Apache
94    for Windows installation, without recompilation of the server.</P>
95
96 <P>To create a module DLL, a small change is necessary to the module's
97    source file: The module record must be exported from the DLL (which
98    will be created later; see below). To do this, add the <CODE
99    >AP_MODULE_DECLARE_DATA</CODE> (defined in the Apache header files) 
100    to your module's module record definition. For example, if your module
101    has:</P>
102 <PRE>
103     module foo_module;
104 </PRE>
105 <P>Replace the above with:</P>
106 <PRE>
107     module AP_MODULE_DECLARE_DATA foo_module;
108 </PRE>
109 <P>Note that this will only be activated on Windows, so the module can
110    continue to be used, unchanged, with Unix if needed. Also, if you are
111    familiar with <CODE>.DEF</CODE> files, you can export the module
112    record with that method instead.</P>
113
114 <P>Now, create a DLL containing your module. You will need to link this
115    against the libhttpd.lib export library that is created when the
116    libhttpd.dll shared library is compiled. You may also have to change
117    the compiler settings to ensure that the Apache header files are
118    correctly located.  You can find this library in your server root's
119    libexec directory.  It is best to grab an existing module .dsp file 
120    from the tree to assure the build environment is configured correctly,
121    or alternately compare the compiler and link options to your .dsp.</P>
122
123 <P>This should create a DLL version of your module. Now simply place it
124    in the <SAMP>modules</SAMP> directory of your server root, and use
125    the <CODE><A HREF="#loadmodule">LoadModule</A></CODE> directive to
126    load it.</P>
127
128 <HR>
129
130 <H2><A NAME="loadfile">LoadFile</A> directive</H2>
131 <!--%plaintext &lt;?INDEX {\tt LoadFile} directive&gt; -->
132 <A
133  HREF="directive-dict.html#Syntax"
134  REL="Help"
135 ><STRONG>Syntax:</STRONG></A> LoadFile <EM>filename</em> 
136    [<em>filename</em>]  ...<BR>
137 <A
138  HREF="directive-dict.html#Context"
139  REL="Help"
140 ><STRONG>Context:</STRONG></A> server config<BR>
141 <A
142  HREF="directive-dict.html#Status"
143  REL="Help"
144 ><STRONG>Status:</STRONG></A> Base<BR>
145 <A
146  HREF="directive-dict.html#Module"
147  REL="Help"
148 ><STRONG>Module:</STRONG></A> mod_so<P>
149
150 The LoadFile directive links in the named object files or libraries
151 when the server is started or restarted; this is used to load
152 additional code which may be required for some module to
153 work. <EM>Filename</EM> is either and absolute path or relative to <A
154 HREF="core.html#serverroot">ServerRoot</A>.<P><HR>
155
156 <H2><A NAME="loadmodule">LoadModule</A> directive</H2>
157 <!--%plaintext &lt;?INDEX {\tt LoadModule} directive&gt; -->
158 <A
159  HREF="directive-dict.html#Syntax"
160  REL="Help"
161 ><STRONG>Syntax:</STRONG></A> LoadModule <EM>module filename</EM><BR>
162 <A
163  HREF="directive-dict.html#Context"
164  REL="Help"
165 ><STRONG>Context:</STRONG></A> server config<BR>
166 <A
167  HREF="directive-dict.html#Status"
168  REL="Help"
169 ><STRONG>Status:</STRONG></A> Base<BR>
170 <A
171  HREF="directive-dict.html#Module"
172  REL="Help"
173 ><STRONG>Module:</STRONG></A> mod_so<P>
174
175 The LoadModule directive links in the object file or library
176 <EM>filename</EM> and adds the module structure named <EM>module</EM>
177 to the list of active modules. <EM>Module</EM> is the name of the
178 external variable of type <CODE>module</CODE> in the file, and is
179 listed as the <a href="module-dict.html#ModuleIdentifier">Module
180 Identifier</a> in the module documentation.  Example:
181 <BLOCKQUOTE><CODE>
182 LoadModule status_module modules/mod_status.so
183 </CODE></BLOCKQUOTE>
184
185 <P>loads the named module from the modules subdirectory of the
186    ServerRoot.<P>
187
188
189 <!--#include virtual="footer.html" -->
190 </BODY>
191 </HTML>
192