1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4 <TITLE>Apache module mod_so</TITLE>
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
15 <!--#include virtual="header.html" -->
16 <H1 ALIGN="CENTER">Module mod_so</H1>
18 <p>This module provides for loading of executable code and modules into the
19 server at start-up or restart time.</p>
22 HREF="module-dict.html#Status"
24 ><STRONG>Status:</STRONG></A> Base (Windows); Optional (Unix)
27 HREF="module-dict.html#SourceFile"
29 ><STRONG>Source File:</STRONG></A> mod_so.c
32 HREF="module-dict.html#ModuleIdentifier"
34 ><STRONG>Module Identifier:</STRONG></A> so_module
37 HREF="module-dict.html#Compatibility"
39 ><STRONG>Compatibility:</STRONG></A> Available in Apache 1.3 and later.
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.
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.
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.
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>
66 <LI><A HREF="#loadfile">LoadFile</A>
67 <LI><A HREF="#loadmodule">LoadModule</A>
70 <H2><A NAME="creating">Creating Loadable Modules for Windows</A></H2>
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>
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>
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>
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>
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
105 <P>Replace the above with:</P>
107 module AP_MODULE_DECLARE_DATA foo_module;
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>
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>
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
130 <H2><A NAME="loadfile">LoadFile</A> directive</H2>
131 <!--%plaintext <?INDEX {\tt LoadFile} directive> -->
133 HREF="directive-dict.html#Syntax"
135 ><STRONG>Syntax:</STRONG></A> LoadFile <EM>filename</em>
136 [<em>filename</em>] ...<BR>
138 HREF="directive-dict.html#Context"
140 ><STRONG>Context:</STRONG></A> server config<BR>
142 HREF="directive-dict.html#Status"
144 ><STRONG>Status:</STRONG></A> Base<BR>
146 HREF="directive-dict.html#Module"
148 ><STRONG>Module:</STRONG></A> mod_so<P>
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>
156 <H2><A NAME="loadmodule">LoadModule</A> directive</H2>
157 <!--%plaintext <?INDEX {\tt LoadModule} directive> -->
159 HREF="directive-dict.html#Syntax"
161 ><STRONG>Syntax:</STRONG></A> LoadModule <EM>module filename</EM><BR>
163 HREF="directive-dict.html#Context"
165 ><STRONG>Context:</STRONG></A> server config<BR>
167 HREF="directive-dict.html#Status"
169 ><STRONG>Status:</STRONG></A> Base<BR>
171 HREF="directive-dict.html#Module"
173 ><STRONG>Module:</STRONG></A> mod_so<P>
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:
182 LoadModule status_module modules/mod_status.so
185 <P>loads the named module from the modules subdirectory of the
189 <!--#include virtual="footer.html" -->