| <!DOCTYPE html SYSTEM "about:legacy-compat"> | |
| <html lang="en"><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| <meta content="width=device-width, initial-scale=1" name="viewport"> | |
| <!-- | |
| XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
| This file is generated from xml source: DO NOT EDIT | |
| XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
| --> | |
| <title>apxs - APache eXtenSion tool - Apache HTTP Server Version 2.5</title> | |
| <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet"> | |
| <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size"> | |
| <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css"><link rel="stylesheet" type="text/css" href="../style/css/prettify.css"> | |
| <script src="../style/scripts/prettify.min.js"> | |
| </script> | |
| <link href="../images/favicon.png" rel="shortcut icon"></head> | |
| <body id="manual-page"><div id="page-header"> | |
| <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="https://cwiki.apache.org/confluence/display/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a> | <a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2">Report a bug</a></p> | |
| <p class="apache">Apache HTTP Server Version 2.5</p> | |
| <img alt="" src="../images/feather.png"></div> | |
| <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif"></a></div> | |
| <div id="path"> | |
| <a href="https://www.apache.org/">Apache</a> > <a href="https://httpd.apache.org/">HTTP Server</a> > <a href="https://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.5</a> > <a href="./">Programs</a></div><div id="page-content"><div id="preamble"><h1>apxs - APache eXtenSion tool</h1> | |
| <button aria-label="Toggle language list" class="lang-toggle"><svg xmlns="http://www.w3.org/2000/svg" stroke-width="2" stroke="currentColor" fill="none" viewBox="0 0 24 24" height="16" width="16"><circle r="10" cy="12" cx="12"/><line y2="12" x2="22" y1="12" x1="2"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg></button> | |
| <div class="toplang"> | |
| <p><span>Available Languages: </span><a href="../en/programs/apxs.html" title="English"> en </a> | | |
| <a href="../fr/programs/apxs.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | | |
| <a href="../ko/programs/apxs.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | | |
| <a href="../tr/programs/apxs.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> | |
| </div> | |
| <p><code class="program"><a href="../programs/apxs.html">apxs</a></code> is a tool for building and installing extension | |
| modules for the Apache HyperText Transfer Protocol (HTTP) server. This is | |
| achieved by building a dynamic shared object (DSO) from one or more source | |
| or object <var>files</var> which then can be loaded into the Apache server | |
| under runtime via the <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> | |
| directive from <code class="module"><a href="../mod/mod_so.html">mod_so</a></code>.</p> | |
| <p>So to use this extension mechanism your platform has to support the DSO | |
| feature and your Apache <code class="program"><a href="../programs/httpd.html">httpd</a></code> binary has to be built with the | |
| <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> module. The <code class="program"><a href="../programs/apxs.html">apxs</a></code> tool automatically | |
| complains if this is not the case. You can check this yourself by manually | |
| running the command</p> | |
| <div class="example"><pre class="prettyprint lang-sh">$ httpd -l</pre> | |
| </div> | |
| <p>The module <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> should be part of the displayed list. | |
| If these requirements are fulfilled you can easily extend your Apache | |
| server's functionality by installing your own modules with the DSO mechanism | |
| by the help of this <code class="program"><a href="../programs/apxs.html">apxs</a></code> tool:</p> | |
| <div class="example"><pre class="prettyprint lang-sh">$ apxs -i -a -c mod_foo.c | |
| gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c | |
| ld -Bshareable -o mod_foo.so mod_foo.o | |
| cp mod_foo.so /path/to/apache/modules/mod_foo.so | |
| chmod 755 /path/to/apache/modules/mod_foo.so | |
| [activating module `foo' in /path/to/apache/etc/httpd.conf] | |
| $ apachectl restart | |
| /path/to/apache/sbin/apachectl restart: httpd not running, trying to start | |
| [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module | |
| /path/to/apache/sbin/apachectl restart: httpd started | |
| $ _</pre> | |
| </div> | |
| <p>The arguments <var>files</var> can be any C source file (.c), a object | |
| file (.o) or even a library archive (.a). The <code class="program"><a href="../programs/apxs.html">apxs</a></code> tool | |
| automatically recognizes these extensions and automatically used the C | |
| source files for compilation while just using the object and archive files | |
| for the linking phase. But when using such pre-compiled objects make sure | |
| they are compiled for position independent code (PIC) to be able to use them | |
| for a dynamically loaded shared object. For instance with GCC you always | |
| just have to use <code>-fpic</code>. For other C compilers consult its | |
| manual page or at watch for the flags <code class="program"><a href="../programs/apxs.html">apxs</a></code> uses to compile the | |
| object files.</p> | |
| <p>For more details about DSO support in Apache read the documentation of | |
| <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> or perhaps even read the | |
| <code>src/modules/standard/mod_so.c</code> source file.</p> | |
| </div> | |
| <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif"> <a href="#synopsis">Synopsis</a></li> | |
| <li><img alt="" src="../images/down.gif"> <a href="#options">Options</a></li> | |
| <li><img alt="" src="../images/down.gif"> <a href="#examples">Examples</a></li> | |
| </ul><h3>See also</h3><ul class="seealso"><li><code class="program"><a href="../programs/apachectl.html">apachectl</a></code></li><li><code class="program"><a href="../programs/httpd.html">httpd</a></code></li></ul></div> | |
| <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif"></a></div> | |
| <div class="section"> | |
| <h2 id="synopsis">Synopsis <a title="Permanent link" href="#synopsis" class="permalink">¶</a></h2> | |
| <p><code><strong>apxs</strong> -<strong>g</strong> | |
| [ -<strong>S</strong> <var>name</var>=<var>value</var> ] | |
| -<strong>n</strong> <var>modname</var></code></p> | |
| <p><code><strong>apxs</strong> -<strong>q</strong> | |
| [ -<strong>v</strong> ] | |
| [ -<strong>S</strong> <var>name</var>=<var>value</var> ] | |
| <var>query</var> ...</code></p> | |
| <p><code><strong>apxs</strong> -<strong>c</strong> | |
| [ -<strong>S</strong> <var>name</var>=<var>value</var> ] | |
| [ -<strong>o</strong> <var>dsofile</var> ] | |
| [ -<strong>I</strong> <var>incdir</var> ] | |
| [ -<strong>D</strong> <var>name</var>=<var>value</var> ] | |
| [ -<strong>L</strong> <var>libdir</var> ] | |
| [ -<strong>l</strong> <var>libname</var> ] | |
| [ -<strong>Wc,</strong><var>compiler-flags</var> ] | |
| [ -<strong>Wl,</strong><var>linker-flags</var> ] | |
| <var>files</var> ...</code></p> | |
| <p><code><strong>apxs</strong> -<strong>i</strong> | |
| [ -<strong>S</strong> <var>name</var>=<var>value</var> ] | |
| [ -<strong>n</strong> <var>modname</var> ] | |
| [ -<strong>a</strong> ] | |
| [ -<strong>A</strong> ] | |
| <var>dso-file</var> ...</code></p> | |
| <p><code><strong>apxs</strong> -<strong>e</strong> | |
| [ -<strong>S</strong> <var>name</var>=<var>value</var> ] | |
| [ -<strong>n</strong> <var>modname</var> ] | |
| [ -<strong>a</strong> ] | |
| [ -<strong>A</strong> ] | |
| <var>dso-file</var> ...</code></p> | |
| </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif"></a></div> | |
| <div class="section"> | |
| <h2 id="options">Options <a title="Permanent link" href="#options" class="permalink">¶</a></h2> | |
| <h3 id="options.common">Common Options</h3> | |
| <dl> | |
| <dt><code>-n <var>modname</var></code></dt> | |
| <dd>This explicitly sets the module name for the <code>-i</code> (install) | |
| and <code>-g</code> (template generation) option. Use this to explicitly | |
| specify the module name. For option <code>-g</code> this is required, for | |
| option <code>-i</code> the <code class="program"><a href="../programs/apxs.html">apxs</a></code> tool tries to determine the | |
| name from the source or (as a fallback) at least by guessing it from the | |
| filename.</dd> | |
| </dl> | |
| <h3 id="options.query">Query Options</h3> | |
| <dl> | |
| <dt><code>-q</code></dt> | |
| <dd>Performs a query for variables and environment settings used to | |
| build <code>httpd</code>. When invoked without <var>query</var> parameters, | |
| it prints all known variables and their values. The optional <code>-v</code> | |
| parameter formats the list output. | |
| <p>Use this to manually determine settings used to build the | |
| <code>httpd</code> that will load your module. For instance use</p> | |
| <div class="example"><pre class="prettyprint lang-sh">INC=-I`apxs -q INCLUDEDIR`</pre> | |
| </div> | |
| <p>inside your own Makefiles if you need manual access to Apache's C | |
| header files.</p></dd> | |
| </dl> | |
| <h3 id="options.conf">Configuration Options</h3> | |
| <dl> | |
| <dt><code>-S <var>name</var>=<var>value</var></code></dt> | |
| <dd>This option changes the apxs settings described above.</dd> | |
| </dl> | |
| <h3 id="options.template">Template Generation Options</h3> | |
| <dl> | |
| <dt><code>-g</code></dt> | |
| <dd>This generates a subdirectory <var>name</var> (see option | |
| <code>-n</code>) and there two files: A sample module source file named | |
| <code>mod_<var>name</var>.c</code> which can be used as a template for | |
| creating your own modules or as a quick start for playing with the | |
| apxs mechanism. And a corresponding <code>Makefile</code> for even easier | |
| build and installing of this module.</dd> | |
| </dl> | |
| <h3 id="options.dso">DSO Compilation Options</h3> | |
| <dl> | |
| <dt><code>-c</code></dt> | |
| <dd>This indicates the compilation operation. It first compiles the C | |
| source files (.c) of <var>files</var> into corresponding object files (.o) | |
| and then builds a dynamically shared object in <var>dsofile</var> by | |
| linking these object files plus the remaining object files (.o and .a) of | |
| <var>files</var>. If no <code>-o</code> option is specified the output | |
| file is guessed from the first filename in <var>files</var> and thus | |
| usually defaults to <code>mod_<var>name</var>.so</code>.</dd> | |
| <dt><code>-o <var>dsofile</var></code></dt> | |
| <dd>Explicitly specifies the filename of the created dynamically shared | |
| object. If not specified and the name cannot be guessed from the | |
| <var>files</var> list, the fallback name <code>mod_unknown.so</code> is | |
| used.</dd> | |
| <dt><code>-D <var>name</var>=<var>value</var></code></dt> | |
| <dd>This option is directly passed through to the compilation command(s). | |
| Use this to add your own defines to the build process.</dd> | |
| <dt><code>-I <var>incdir</var></code></dt> | |
| <dd>This option is directly passed through to the compilation command(s). | |
| Use this to add your own include directories to search to the build | |
| process.</dd> | |
| <dt><code>-L <var>libdir</var></code></dt> | |
| <dd>This option is directly passed through to the linker command. Use this | |
| to add your own library directories to search to the build process.</dd> | |
| <dt><code>-l <var>libname</var></code></dt> | |
| <dd>This option is directly passed through to the linker command. Use this | |
| to add your own libraries to search to the build process.</dd> | |
| <dt><code>-Wc,<var>compiler-flags</var></code></dt> | |
| <dd>This option passes <var>compiler-flags</var> as additional flags to | |
| the <code>libtool --mode=compile</code> command. Use this to add local | |
| compiler-specific options.</dd> | |
| <dt><code>-Wl,<var>linker-flags</var></code></dt> | |
| <dd>This option passes <var>linker-flags</var> as additional | |
| flags to the <code>libtool --mode=link</code> command. Use this | |
| to add local linker-specific options.</dd> | |
| <dt><code>-p</code></dt> | |
| <dd>This option causes apxs to link against the apr/apr-util libraries. | |
| This is useful when compiling helper programs that use the apr/apr-util | |
| libraries.</dd> | |
| </dl> | |
| <h3 id="options.dsoinstall">DSO Installation and Configuration Options</h3> | |
| <dl> | |
| <dt><code>-i</code></dt> | |
| <dd>This indicates the installation operation and installs one or more | |
| dynamically shared objects into the server's <var>modules</var> | |
| directory.</dd> | |
| <dt><code>-a</code></dt> | |
| <dd>This activates the module by automatically adding a corresponding | |
| <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> line to Apache's | |
| <code>httpd.conf</code> configuration file, or by enabling it if it | |
| already exists.</dd> | |
| <dt><code>-A</code></dt> | |
| <dd>Same as option <code>-a</code> but the created <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> directive is prefixed with a hash | |
| sign (<code>#</code>), <em>i.e.</em>, the module is just prepared for | |
| later activation but initially disabled.</dd> | |
| <dt><code>-e</code></dt> | |
| <dd>This indicates the editing operation, which can be used with the | |
| <code>-a</code> and <code>-A</code> options similarly to the | |
| <code>-i</code> operation to edit Apache's <code>httpd.conf</code> | |
| configuration file without attempting to install the module.</dd> | |
| </dl> | |
| </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif"></a></div> | |
| <div class="section"> | |
| <h2 id="examples">Examples <a title="Permanent link" href="#examples" class="permalink">¶</a></h2> | |
| <p>Assume you have an Apache module named <code>mod_foo.c</code> available | |
| which should extend Apache's server functionality. To accomplish this you | |
| first have to compile the C source into a shared object suitable for loading | |
| into the Apache server under runtime via the following command:</p> | |
| <div class="example"><pre class="prettyprint lang-sh">$ apxs -c mod_foo.c | |
| /path/to/libtool --mode=compile gcc ... -c mod_foo.c | |
| /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo | |
| $ _</pre> | |
| </div> | |
| <p>Then you have to update the Apache configuration by making sure a | |
| <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> directive is present to | |
| load this shared object. To simplify this step <code class="program"><a href="../programs/apxs.html">apxs</a></code> provides | |
| an automatic way to install the shared object in its "modules" directory | |
| and updating the <code>httpd.conf</code> file accordingly. This can be | |
| achieved by running:</p> | |
| <div class="example"><pre class="prettyprint lang-sh">$ apxs -i -a mod_foo.la | |
| /path/to/instdso.sh mod_foo.la /path/to/apache/modules | |
| /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules | |
| ... | |
| chmod 755 /path/to/apache/modules/mod_foo.so | |
| [activating module `foo' in /path/to/apache/conf/httpd.conf] | |
| $ _</pre> | |
| </div> | |
| <p>This way a line named</p> | |
| <div class="example"><pre class="prettyprint lang-config">LoadModule foo_module modules/mod_foo.so</pre> | |
| </div> | |
| <p>is added to the configuration file if still not present. If you want to | |
| have this disabled per default use the <code>-A</code> option, | |
| <em>i.e.</em></p> | |
| <div class="example"><pre class="prettyprint lang-sh">$ apxs -i -A mod_foo.c</pre> | |
| </div> | |
| <p>For a quick test of the apxs mechanism you can create a sample Apache | |
| module template plus a corresponding Makefile via:</p> | |
| <div class="example"><pre class="prettyprint lang-sh">$ apxs -g -n foo | |
| Creating [DIR] foo | |
| Creating [FILE] foo/Makefile | |
| Creating [FILE] foo/modules.mk | |
| Creating [FILE] foo/mod_foo.c | |
| Creating [FILE] foo/.deps | |
| $ _</pre> | |
| </div> | |
| <p>Then you can immediately compile this sample module into a shared object | |
| and load it into the Apache server:</p> | |
| <div class="example"><pre class="prettyprint lang-sh">$ cd foo | |
| $ make all reload | |
| apxs -c mod_foo.c | |
| /path/to/libtool --mode=compile gcc ... -c mod_foo.c | |
| /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo | |
| apxs -i -a -n "foo" mod_foo.la | |
| /path/to/instdso.sh mod_foo.la /path/to/apache/modules | |
| /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules | |
| ... | |
| chmod 755 /path/to/apache/modules/mod_foo.so | |
| [activating module `foo' in /path/to/apache/conf/httpd.conf] | |
| apachectl restart | |
| /path/to/apache/sbin/apachectl restart: httpd not running, trying to start | |
| [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module | |
| /path/to/apache/sbin/apachectl restart: httpd started | |
| $ _</pre> | |
| </div> | |
| </div></div> | |
| <div class="bottomlang"> | |
| <p><span>Available Languages: </span><a href="../en/programs/apxs.html" title="English"> en </a> | | |
| <a href="../fr/programs/apxs.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | | |
| <a href="../ko/programs/apxs.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | | |
| <a href="../tr/programs/apxs.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> | |
| </div><div id="footer"> | |
| <p class="apache">Copyright 2026 The Apache Software Foundation.<br>Licensed under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> | |
| <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="https://cwiki.apache.org/confluence/display/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a> | <a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2">Report a bug</a></p></div><script><!--//--><![CDATA[//><!-- | |
| if (typeof(prettyPrint) !== 'undefined') { | |
| prettyPrint(); | |
| } | |
| var langToggle = document.querySelector('.lang-toggle'); | |
| var topLang = document.querySelector('.toplang'); | |
| if (langToggle && topLang) { | |
| langToggle.addEventListener('click', function() { topLang.classList.toggle('open'); }); | |
| } | |
| var qv = document.getElementById('quickview'); | |
| if (qv) { | |
| document.body.appendChild(qv); | |
| var qvBtn = document.createElement('button'); | |
| qvBtn.className = 'qv-toggle'; | |
| qvBtn.setAttribute('aria-label', 'Toggle page navigation'); | |
| qvBtn.innerHTML = '☰'; | |
| document.body.appendChild(qvBtn); | |
| qvBtn.addEventListener('click', function() { | |
| var isOpen = qv.classList.toggle('open'); | |
| if (isOpen) { | |
| qv.style.top = window.scrollY + 10 + 'px'; | |
| } | |
| }); | |
| window.addEventListener('scroll', function() { qv.classList.remove('open'); }); | |
| } | |
| //--><!]]></script> | |
| </body></html> |