Home > Articles

  • Print
  • + Share This
This chapter is from the book

Dynamic Shared Objects

Many Unix implementations provide the capability of specifying at run time which portions of an executable are to be included in httpd and which are to be excluded. The term for these precompiled chunks is shared objects. The main advantage of using DSOs is that you can effectively rebuild your server at run time by modifying the directives of your configuration file and restarting the server. Note, however, that not all operating systems support DSO functionality.

Preparing Apache for DSOs

Some preparation of the core httpd executable is necessary in order to take advantage of DSO functionality. The modules that will be compiled as DSOs need to have access to the program variables stored in httpd's symbol table.

Preparing the executable usually is a simple matter of using the --enable-module option to the configure script to enable the shared object (so) module:

./configure --prefix=/path/to/apache --enable-module=so

Then reconfigure and reinstall your executable. If all goes well, you should see mod_so compiled into your new executable. Check with the following command:

httpd -l | grep mod_so 

On some platforms, it also is necessary to place the complete Apache executable in a DSO library. The --enable-rule= SHARED_CORE option forces the linker to export the symbol table for later use by third-party modules.


The next step is to create your shared object modules. Note that modules must be specifically compiled as DSOs—it doesn't just happen. If the module is part of the distribution, it is possible to do this with the --enable-shared option to the configure script:

./configure --prefix=/path/to/apache/root --enable-shared=modulename


It is also possible to compile a DSO Apache module entirely independent of the Apache source code tree. The apxs (APache eXtenSion) program was created for this purpose. When the original Apache binary is compiled, the apxs program is informed of the symbol table information the binary needs to know. The apxs program can then be used to build modules as DSOs.

As an example, consider the compilation of mod_perl as a DSO using apxs:

$ cd /path/to/mod_perl
$ apxs -c mod_perl.c
$ apxs -i -a -n perl mod_perl.so

Third-party modules (mod_perl, mod_php) typically come with their own instructions for compiling as shared objects.


The Apache module mod_so enables you to specify at run time which shared object modules are to be included via the Load-Module directive. You need to specify the name of the module and the path to the shared object file in the directive:

LoadModule perl_module libexec/libperl.so 

Typically (and by default), such files are found in a library directory named libexec under the ServerRoot directory.

  • + Share This
  • 🔖 Save To Your Account