1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>apxs - APache eXtenSion tool - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
15 <p class="apache">Apache HTTP Server Version 2.1</p>
16 <img alt="" src="../images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
19 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.1</a> > <a href="./">Programs</a></div><div id="page-content"><div id="preamble"><h1>apxs - APache eXtenSion tool</h1>
21 <p><span>Available Languages: </span><a href="../en/programs/apxs.html" hreflang="en" title="English"> en </a></p>
24 <p><code>apxs</code> is a tool for building and installing extension
25 modules for the Apache HyperText Transfer Protocol (HTTP) server. This is
26 achieved by building a dynamic shared object (DSO) from one or more source
27 or object <var>files</var> which then can be loaded into the Apache server
28 under runtime via the <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code>
29 directive from <code class="module"><a href="../mod/mod_so.html">mod_so</a></code>.</p>
31 <p>So to use this extension mechanism your platform has to support the DSO
32 feature and your Apache <code>httpd</code> binary has to be built with the
33 <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> module. The <code>apxs</code> tool automatically
34 complains if this is not the case. You can check this yourself by manually
35 running the command</p>
37 <div class="example"><p><code>
41 <p>The module <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> should be part of the displayed list.
42 If these requirements are fulfilled you can easily extend your Apache
43 server's functionality by installing your own modules with the DSO mechanism
44 by the help of this <code>apxs</code> tool:</p>
46 <div class="example"><p><code>
47 $ apxs -i -a -c mod_foo.c<br />
48 gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c<br />
49 ld -Bshareable -o mod_foo.so mod_foo.o<br />
50 cp mod_foo.so /path/to/apache/modules/mod_foo.so<br />
51 chmod 755 /path/to/apache/modules/mod_foo.so<br />
52 [activating module `foo' in /path/to/apache/etc/httpd.conf]<br />
53 $ apachectl restart<br />
54 /path/to/apache/sbin/apachectl restart: httpd not running, trying to start<br />
55 [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module<br />
56 /path/to/apache/sbin/apachectl restart: httpd started<br />
60 <p>The arguments <var>files</var> can be any C source file (.c), a object
61 file (.o) or even a library archive (.a). The <code>apxs</code> tool
62 automatically recognizes these extensions and automatically used the C
63 source files for compilation while just using the object and archive files
64 for the linking phase. But when using such pre-compiled objects make sure
65 they are compiled for position independent code (PIC) to be able to use them
66 for a dynamically loaded shared object. For instance with GCC you always
67 just have to use <code>-fpic</code>. For other C compilers consult its
68 manual page or at watch for the flags <code>apxs</code> uses to compile the
71 <p>For more details about DSO support in Apache read the documentation of
72 <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> or perhaps even read the
73 <code>src/modules/standard/mod_so.c</code> source file.</p>
75 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#synopsis">Synopsis</a></li>
76 <li><img alt="" src="../images/down.gif" /> <a href="#options">Options</a></li>
77 <li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
78 </ul><h3>See also</h3><ul class="seealso"><li><a href="apachectl.html">apachectl</a></li><li><a href="httpd.html">httpd</a></li></ul></div>
79 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
81 <h2><a name="synopsis" id="synopsis">Synopsis</a></h2>
82 <p><code><strong>apxs</strong> -<strong>g</strong>
83 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
84 -<strong>n</strong> <var>modname</var></code></p>
86 <p><code><strong>apxs</strong> -<strong>q</strong>
87 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
88 <var>query</var> ...</code></p>
90 <p><code><strong>apxs</strong> -<strong>c</strong>
91 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
92 [ -<strong>o</strong> <var>dsofile</var> ]
93 [ -<strong>I</strong> <var>incdir</var> ]
94 [ -<strong>D</strong> <var>name</var>=<var>value</var> ]
95 [ -<strong>L</strong> <var>libdir</var> ]
96 [ -<strong>l</strong> <var>libname</var> ]
97 [ -<strong>Wc,</strong><var>compiler-flags</var> ]
98 [ -<strong>Wl,</strong><var>linker-flags</var> ]
99 <var>files</var> ...</code></p>
101 <p><code><strong>apxs</strong> -<strong>i</strong>
102 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
103 [ -<strong>n</strong> <var>modname</var> ]
104 [ -<strong>a</strong> ]
105 [ -<strong>A</strong> ]
106 <var>dso-file</var> ...</code></p>
108 <p><code><strong>apxs</strong> -<strong>e</strong>
109 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
110 [ -<strong>n</strong> <var>modname</var> ]
111 [ -<strong>a</strong> ]
112 [ -<strong>A</strong> ]
113 <var>dso-file</var> ...</code></p>
114 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
115 <div class="section">
116 <h2><a name="options" id="options">Options</a></h2>
117 <h3><a name="options.common" id="options.common">Common Options</a></h3>
119 <dt><code>-n <var>modname</var></code></dt>
120 <dd>This explicitly sets the module name for the <code>-i</code> (install)
121 and <code>-g</code> (template generation) option. Use this to explicitly
122 specify the module name. For option <code>-g</code> this is required, for
123 option <code>-i</code> the <code>apxs</code> tool tries to determine the
124 name from the source or (as a fallback) at least by guessing it from the
129 <h3><a name="options.query" id="options.query">Query Options</a></h3>
131 <dt><code>-q</code></dt>
132 <dd>Performs a query for <code>apxs</code>'s knowledge about certain
133 settings. The <var>query</var> parameters can be one or more of the
134 following strings: <code>CC</code>, <code>CFLAGS</code>,
135 <code>CFLAGS_SHLIB</code>, <code>INCLUDEDIR</code>, <code>LD_SHLIB</code>,
136 <code>LDFLAGS_SHLIB</code>, <code>LIBEXECDIR</code>,
137 <code>LIBS_SHLIB</code>, <code>SBINDIR</code>, <code>SYSCONFDIR</code>,
140 <p>Use this for manually determining settings. For instance use</p>
141 <div class="example"><p><code>
142 INC=-I`apxs -q INCLUDEDIR`
145 <p>inside your own Makefiles if you need manual access to Apache's C
146 header files.</p></dd>
150 <h3><a name="options.conf" id="options.conf">Configuration Options</a></h3>
152 <dt><code>-S <var>name</var>=<var>value</var></code></dt>
153 <dd>This option changes the apxs settings described above.</dd>
157 <h3><a name="options.template" id="options.template">Template Generation Options</a></h3>
159 <dt><code>-g</code></dt>
160 <dd>This generates a subdirectory <var>name</var> (see option
161 <code>-n</code>) and there two files: A sample module source file named
162 <code>mod_<var>name</var>.c</code> which can be used as a template for
163 creating your own modules or as a quick start for playing with the
164 apxs mechanism. And a corresponding <code>Makefile</code> for even easier
165 build and installing of this module.</dd>
169 <h3><a name="options.dso" id="options.dso">DSO Compilation Options</a></h3>
171 <dt><code>-c</code></dt>
172 <dd>This indicates the compilation operation. It first compiles the C
173 source files (.c) of <var>files</var> into corresponding object files (.o)
174 and then builds a dynamically shared object in <var>dsofile</var> by
175 linking these object files plus the remaining object files (.o and .a) of
176 <var>files</var>. If no <code>-o</code> option is specified the output
177 file is guessed from the first filename in <var>files</var> and thus
178 usually defaults to <code>mod_<var>name</var>.so</code>.</dd>
180 <dt><code>-o <var>dsofile</var></code></dt>
181 <dd>Explicitly specifies the filename of the created dynamically shared
182 object. If not specified and the name cannot be guessed from the
183 <var>files</var> list, the fallback name <code>mod_unknown.so</code> is
186 <dt><code>-D <var>name</var>=<var>value</var></code></dt>
187 <dd>This option is directly passed through to the compilation command(s).
188 Use this to add your own defines to the build process.</dd>
190 <dt><code>-I <var>incdir</var></code></dt>
191 <dd>This option is directly passed through to the compilation command(s).
192 Use this to add your own include directories to search to the build
195 <dt><code>-L <var>libdir</var></code></dt>
196 <dd>This option is directly passed through to the linker command. Use this
197 to add your own library directories to search to the build process.</dd>
199 <dt><code>-l <var>libname</var></code></dt>
200 <dd>This option is directly passed through to the linker command. Use this
201 to add your own libraries to search to the build process.</dd>
203 <dt><code>-Wc,<var>compiler-flags</var></code></dt>
204 <dd>This option passes <var>compiler-flags</var> as additional flags to
205 the compiler command. Use this to add local compiler-specific options.</dd>
207 <dt><code>-Wl,<var>linker-flags</var></code></dt>
208 <dd>This option passes <var>linker-flags</var> as additional flags to
209 the linker command. Use this to add local linker-specific options.</dd>
213 <h3><a name="options.dsoinstall" id="options.dsoinstall">DSO Installation and Configuration Options</a></h3>
216 <dt><code>-i</code></dt>
217 <dd>This indicates the installation operation and installs one or more
218 dynamically shared objects into the server's <var>modules</var>
221 <dt><code>-a</code></dt>
222 <dd>This activates the module by automatically adding a corresponding
223 <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> line to Apache's
224 <code>httpd.conf</code> configuration file, or by enabling it if it
227 <dt><code>-A</code></dt>
228 <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
229 sign (<code>#</code>), <em>i.e.</em>, the module is just prepared for
230 later activation but initially disabled.</dd>
232 <dt><code>-e</code></dt>
233 <dd>This indicates the editing operation, which can be used with the
234 <code>-a</code> and <code>-A</code> options similarly to the
235 <code>-i</code> operation to edit Apache's <code>httpd.conf</code>
236 configuration file without attempting to install the module.</dd>
239 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
240 <div class="section">
241 <h2><a name="examples" id="examples">Examples</a></h2>
242 <p>Assume you have an Apache module named <code>mod_foo.c</code> available
243 which should extend Apache's server functionality. To accomplish this you
244 first have to compile the C source into a shared object suitable for loading
245 into the Apache server under runtime via the following command:</p>
247 <div class="example"><p><code>
248 $ apxs -c mod_foo.c<br />
249 gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c<br />
250 ld -Bshareable -o mod_foo.so mod_foo.o<br />
254 <p>Then you have to update the Apache configuration by making sure a
255 <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> directive is present to
256 load this shared object. To simplify this step <code>apxs</code> provides
257 an automatic way to install the shared object in its "modules" directory
258 and updating the <code>httpd.conf</code> file accordingly. This can be
259 achieved by running:</p>
261 <div class="example"><p><code>
262 $ apxs -i -a mod_foo.c<br />
263 cp mod_foo.so /path/to/apache/modules/mod_foo.so<br />
264 chmod 755 /path/to/apache/modules/mod_foo.so<br />
265 [activating module `foo' in /path/to/apache/etc/httpd.conf]<br />
269 <p>This way a line named</p>
271 <div class="example"><p><code>
272 LoadModule foo_module modules/mod_foo.so
275 <p>is added to the configuration file if still not present. If you want to
276 have this disabled per default use the <code>-A</code> option,
279 <div class="example"><p><code>
280 $ apxs -i -A mod_foo.c
283 <p>For a quick test of the apxs mechanism you can create a sample Apache
284 module template plus a corresponding Makefile via:</p>
286 <div class="example"><p><code>
287 $ apxs -g -n foo<br />
288 Creating [DIR] foo<br />
289 Creating [FILE] foo/Makefile<br />
290 Creating [FILE] foo/mod_foo.c<br />
294 <p>Then you can immediately compile this sample module into a shared object
295 and load it into the Apache server:</p>
297 <div class="example"><p><code>
299 $ make all reload<br />
300 apxs -c mod_foo.c<br />
301 gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c<br />
302 ld -Bshareable -o mod_foo.so mod_foo.o<br />
303 apxs -i -a -n "foo" mod_foo.so<br />
304 cp mod_foo.so /path/to/apache/modules/mod_foo.so<br />
305 chmod 755 /path/to/apache/modules/mod_foo.so<br />
306 [activating module `foo' in /path/to/apache/etc/httpd.conf]<br />
307 apachectl restart<br />
308 /path/to/apache/sbin/apachectl restart: httpd not running, trying to start<br />
309 [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module<br />
310 /path/to/apache/sbin/apachectl restart: httpd started<br />
314 <p>You can even use <code>apxs</code> to compile complex modules outside the
315 Apache source tree, like PHP3:</p>
317 <div class="example"><p><code>
319 $ ./configure --with-shared-apache=../apache-1.3<br />
320 $ apxs -c -o libphp3.so mod_php3.c libmodphp3-so.a<br />
321 gcc -fpic -DSHARED_MODULE -I/tmp/apache/include -c mod_php3.c<br />
322 ld -Bshareable -o libphp3.so mod_php3.o libmodphp3-so.a<br />
326 <p>because <code>apxs</code> automatically recognized C source files and
327 object files. Only C source files are compiled while remaining object
328 files are used for the linking phase.</p>
330 <div class="bottomlang">
331 <p><span>Available Languages: </span><a href="../en/programs/apxs.html" hreflang="en" title="English"> en </a></p>
332 </div><div id="footer">
333 <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
334 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>