dso.html revision 4b1aa14cf1e3fcb01bcef47bc45a4414047ee476
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
355b4669e025ff377602b6fc7caaf30dbc218371jacobs BGCOLOR="#FFFFFF"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs TEXT="#000000"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs LINK="#0000FF"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs VLINK="#000080"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs ALINK="#FF0000"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<!--#include virtual="header.html" -->
355b4669e025ff377602b6fc7caaf30dbc218371jacobsDynamic Shared Object (DSO) Support
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<p>The Apache HTTP Server is a modular program where the administrator
355b4669e025ff377602b6fc7caaf30dbc218371jacobscan choose the functionality to include in the server by selecting a
355b4669e025ff377602b6fc7caaf30dbc218371jacobsset of modules. The modules can be statically compiled into the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<code>httpd</code> binary when the server is built. Alternatively,
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmodules can be compiled as Dynamic Shared Objects (DSOs) that exist
355b4669e025ff377602b6fc7caaf30dbc218371jacobsseparately from the main <code>httpd</code> binary file. DSO modules
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmay be compiled at the time the server is built, or they may be
355b4669e025ff377602b6fc7caaf30dbc218371jacobscompiled and added at a later time using the Apache Extension Tool (<a
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<p>This document describes how to use DSO modules as well as the theory
355b4669e025ff377602b6fc7caaf30dbc218371jacobsbehind their use.</p>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<li><a href="#advantages">Advantages and Disadvantages</a></li>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<A HREF="mod/mod_so.html#loadmodule">LoadModule</A><br>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<P>The DSO support for loading individual Apache modules is based on a
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmodule named <A HREF="mod/mod_so.html"><CODE>mod_so.c</CODE></A> which
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmust be statically compiled into the Apache core. It is the only
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmodule besides <CODE>core.c</CODE> which cannot be put into a DSO
355b4669e025ff377602b6fc7caaf30dbc218371jacobsitself. Practically all other distributed Apache modules then can
355b4669e025ff377602b6fc7caaf30dbc218371jacobsthen be placed into a DSO by individually enabling the DSO build for
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<CODE>--enable-<i>module</i>=shared</CODE> option as disucussed in the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<a href="install.html">install documentation</a>. After a module is
355b4669e025ff377602b6fc7caaf30dbc218371jacobscompiled into a DSO named <CODE>mod_foo.so</CODE> you can use <A
355b4669e025ff377602b6fc7caaf30dbc218371jacobsHREF="mod/mod_so.html#loadmodule"><CODE>LoadModule</CODE></A> command
355b4669e025ff377602b6fc7caaf30dbc218371jacobsin your <CODE>httpd.conf</CODE> file to load this module at server
355b4669e025ff377602b6fc7caaf30dbc218371jacobsstartup or restart.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<P>To simplify this creation of DSO files for Apache modules
355b4669e025ff377602b6fc7caaf30dbc218371jacobs(especially for third-party modules) a new support program named <a
355b4669e025ff377602b6fc7caaf30dbc218371jacobshref="programs/apxs.html">apxs</a> (<EM>APache eXtenSion</EM>) is
355b4669e025ff377602b6fc7caaf30dbc218371jacobsavailable. It can be used to build DSO based modules <EM>outside
355b4669e025ff377602b6fc7caaf30dbc218371jacobsof</EM> the Apache source tree. The idea is simple: When installing
355b4669e025ff377602b6fc7caaf30dbc218371jacobsApache the <CODE>configure</CODE>'s <CODE>make install</CODE>
355b4669e025ff377602b6fc7caaf30dbc218371jacobsprocedure installs the Apache C header files and puts the
355b4669e025ff377602b6fc7caaf30dbc218371jacobsplatform-dependent compiler and linker flags for building DSO files
355b4669e025ff377602b6fc7caaf30dbc218371jacobsinto the <CODE>apxs</CODE> program. This way the user can use
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<CODE>apxs</CODE> to compile his Apache module sources without the
355b4669e025ff377602b6fc7caaf30dbc218371jacobsApache distribution source tree and without having to fiddle with the
355b4669e025ff377602b6fc7caaf30dbc218371jacobsplatform-dependent compiler and linker flags for DSO support.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<P>To give you an overview of the DSO features of Apache 2.0, here is a short
355b4669e025ff377602b6fc7caaf30dbc218371jacobsand concise summary:
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<LI>Build and install a <EM>distributed</EM> Apache module, say
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<CODE>mod_foo.c</CODE>, into its own DSO <CODE>mod_foo.so</CODE>:
355b4669e025ff377602b6fc7caaf30dbc218371jacobs --enable-foo=shared
355b4669e025ff377602b6fc7caaf30dbc218371jacobs$ make install
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<LI>Build and install a <EM>third-party</EM> Apache module, say
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<CODE>mod_foo.c</CODE>, into its own DSO <CODE>mod_foo.so</CODE>:
355b4669e025ff377602b6fc7caaf30dbc218371jacobs$ /configure --add-module=module_type:/path/to/3rdparty/mod_foo.c
355b4669e025ff377602b6fc7caaf30dbc218371jacobs --enable-foo=shared
355b4669e025ff377602b6fc7caaf30dbc218371jacobs$ make install
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<LI>Configure Apache for <EM>later installation</EM> of shared modules:
355b4669e025ff377602b6fc7caaf30dbc218371jacobs$ /configure --enable-so
355b4669e025ff377602b6fc7caaf30dbc218371jacobs$ make install
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<LI>Build and install a <EM>third-party</EM> Apache module, say
355b4669e025ff377602b6fc7caaf30dbc218371jacobs<CODE>mod_foo.c</CODE>, into its own DSO <CODE>mod_foo.so</CODE> <EM>outside
355b4669e025ff377602b6fc7caaf30dbc218371jacobsof</EM> the Apache source tree using <a href="programs/apxs.html">apxs</a>:
355b4669e025ff377602b6fc7caaf30dbc218371jacobs$ apxs -i -a -n foo mod_foo.so
0a44ef6d9afbfe052a7e975f55ea0d2954b62a82jacobs<p>In all cases, once the shared module is compiled, you must use a <A
<!--#include virtual="footer.html" -->