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.0</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/">Documentation</a> > <a href="../">Version 2.0</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" title="English"> en </a> |
22 <a href="../ko/programs/apxs.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
23 <a href="../tr/programs/apxs.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
26 <p><code>apxs</code> is a tool for building and installing extension
27 modules for the Apache HyperText Transfer Protocol (HTTP) server. This is
28 achieved by building a dynamic shared object (DSO) from one or more source
29 or object <var>files</var> which then can be loaded into the Apache server
30 under runtime via the <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code>
31 directive from <code class="module"><a href="../mod/mod_so.html">mod_so</a></code>.</p>
33 <p>So to use this extension mechanism your platform has to support the DSO
34 feature and your Apache <code class="program"><a href="../programs/httpd.html">httpd</a></code> binary has to be built with the
35 <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> module. The <code>apxs</code> tool automatically
36 complains if this is not the case. You can check this yourself by manually
37 running the command</p>
39 <div class="example"><p><code>
43 <p>The module <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> should be part of the displayed list.
44 If these requirements are fulfilled you can easily extend your Apache
45 server's functionality by installing your own modules with the DSO mechanism
46 by the help of this <code>apxs</code> tool:</p>
48 <div class="example"><p><code>
49 $ apxs -i -a -c mod_foo.c<br />
50 gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c<br />
51 ld -Bshareable -o mod_foo.so mod_foo.o<br />
52 cp mod_foo.so /path/to/apache/modules/mod_foo.so<br />
53 chmod 755 /path/to/apache/modules/mod_foo.so<br />
54 [activating module `foo' in /path/to/apache/etc/httpd.conf]<br />
55 $ apachectl restart<br />
56 /path/to/apache/sbin/apachectl restart: httpd not running, trying to start<br />
57 [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module<br />
58 /path/to/apache/sbin/apachectl restart: httpd started<br />
62 <p>The arguments <var>files</var> can be any C source file (.c), a object
63 file (.o) or even a library archive (.a). The <code>apxs</code> tool
64 automatically recognizes these extensions and automatically used the C
65 source files for compilation while just using the object and archive files
66 for the linking phase. But when using such pre-compiled objects make sure
67 they are compiled for position independent code (PIC) to be able to use them
68 for a dynamically loaded shared object. For instance with GCC you always
69 just have to use <code>-fpic</code>. For other C compilers consult its
70 manual page or at watch for the flags <code>apxs</code> uses to compile the
73 <p>For more details about DSO support in Apache read the documentation of
74 <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> or perhaps even read the
75 <code>src/modules/standard/mod_so.c</code> source file.</p>
77 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#synopsis">Synopsis</a></li>
78 <li><img alt="" src="../images/down.gif" /> <a href="#options">Options</a></li>
79 <li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
80 </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>
81 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
83 <h2><a name="synopsis" id="synopsis">Synopsis</a></h2>
84 <p><code><strong>apxs</strong> -<strong>g</strong>
85 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
86 -<strong>n</strong> <var>modname</var></code></p>
88 <p><code><strong>apxs</strong> -<strong>q</strong>
89 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
90 <var>query</var> ...</code></p>
92 <p><code><strong>apxs</strong> -<strong>c</strong>
93 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
94 [ -<strong>o</strong> <var>dsofile</var> ]
95 [ -<strong>I</strong> <var>incdir</var> ]
96 [ -<strong>D</strong> <var>name</var>=<var>value</var> ]
97 [ -<strong>L</strong> <var>libdir</var> ]
98 [ -<strong>l</strong> <var>libname</var> ]
99 [ -<strong>Wc,</strong><var>compiler-flags</var> ]
100 [ -<strong>Wl,</strong><var>linker-flags</var> ]
101 <var>files</var> ...</code></p>
103 <p><code><strong>apxs</strong> -<strong>i</strong>
104 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
105 [ -<strong>n</strong> <var>modname</var> ]
106 [ -<strong>a</strong> ]
107 [ -<strong>A</strong> ]
108 <var>dso-file</var> ...</code></p>
110 <p><code><strong>apxs</strong> -<strong>e</strong>
111 [ -<strong>S</strong> <var>name</var>=<var>value</var> ]
112 [ -<strong>n</strong> <var>modname</var> ]
113 [ -<strong>a</strong> ]
114 [ -<strong>A</strong> ]
115 <var>dso-file</var> ...</code></p>
116 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
117 <div class="section">
118 <h2><a name="options" id="options">Options</a></h2>
119 <h3><a name="options.common" id="options.common">Common Options</a></h3>
121 <dt><code>-n <var>modname</var></code></dt>
122 <dd>This explicitly sets the module name for the <code>-i</code> (install)
123 and <code>-g</code> (template generation) option. Use this to explicitly
124 specify the module name. For option <code>-g</code> this is required, for
125 option <code>-i</code> the <code>apxs</code> tool tries to determine the
126 name from the source or (as a fallback) at least by guessing it from the
131 <h3><a name="options.query" id="options.query">Query Options</a></h3>
133 <dt><code>-q</code></dt>
134 <dd>Performs a query for <code>apxs</code>'s knowledge about certain
135 settings. The <var>query</var> parameters can be one or more of the
136 following strings: <code>CC</code>, <code>CFLAGS</code>,
137 <code>CFLAGS_SHLIB</code>, <code>INCLUDEDIR</code>, <code>LD_SHLIB</code>,
138 <code>LDFLAGS_SHLIB</code>, <code>LIBEXECDIR</code>,
139 <code>LIBS_SHLIB</code>, <code>SBINDIR</code>, <code>SYSCONFDIR</code>,
142 <p>Use this for manually determining settings. For instance use</p>
143 <div class="example"><p><code>
144 INC=-I`apxs -q INCLUDEDIR`
147 <p>inside your own Makefiles if you need manual access to Apache's C
148 header files.</p></dd>
152 <h3><a name="options.conf" id="options.conf">Configuration Options</a></h3>
154 <dt><code>-S <var>name</var>=<var>value</var></code></dt>
155 <dd>This option changes the apxs settings described above.</dd>
159 <h3><a name="options.template" id="options.template">Template Generation Options</a></h3>
161 <dt><code>-g</code></dt>
162 <dd>This generates a subdirectory <var>name</var> (see option
163 <code>-n</code>) and there two files: A sample module source file named
164 <code>mod_<var>name</var>.c</code> which can be used as a template for
165 creating your own modules or as a quick start for playing with the
166 apxs mechanism. And a corresponding <code>Makefile</code> for even easier
167 build and installing of this module.</dd>
171 <h3><a name="options.dso" id="options.dso">DSO Compilation Options</a></h3>
173 <dt><code>-c</code></dt>
174 <dd>This indicates the compilation operation. It first compiles the C
175 source files (.c) of <var>files</var> into corresponding object files (.o)
176 and then builds a dynamically shared object in <var>dsofile</var> by
177 linking these object files plus the remaining object files (.o and .a) of
178 <var>files</var>. If no <code>-o</code> option is specified the output
179 file is guessed from the first filename in <var>files</var> and thus
180 usually defaults to <code>mod_<var>name</var>.so</code>.</dd>
182 <dt><code>-o <var>dsofile</var></code></dt>
183 <dd>Explicitly specifies the filename of the created dynamically shared
184 object. If not specified and the name cannot be guessed from the
185 <var>files</var> list, the fallback name <code>mod_unknown.so</code> is
188 <dt><code>-D <var>name</var>=<var>value</var></code></dt>
189 <dd>This option is directly passed through to the compilation command(s).
190 Use this to add your own defines to the build process.</dd>
192 <dt><code>-I <var>incdir</var></code></dt>
193 <dd>This option is directly passed through to the compilation command(s).
194 Use this to add your own include directories to search to the build
197 <dt><code>-L <var>libdir</var></code></dt>
198 <dd>This option is directly passed through to the linker command. Use this
199 to add your own library directories to search to the build process.</dd>
201 <dt><code>-l <var>libname</var></code></dt>
202 <dd>This option is directly passed through to the linker command. Use this
203 to add your own libraries to search to the build process.</dd>
205 <dt><code>-Wc,<var>compiler-flags</var></code></dt>
206 <dd>This option passes <var>compiler-flags</var> as additional flags to
207 the compiler command. Use this to add local compiler-specific options.</dd>
209 <dt><code>-Wl,<var>linker-flags</var></code></dt>
210 <dd>This option passes <var>linker-flags</var> as additional flags to
211 the linker command. Use this to add local linker-specific options.</dd>
215 <h3><a name="options.dsoinstall" id="options.dsoinstall">DSO Installation and Configuration Options</a></h3>
218 <dt><code>-i</code></dt>
219 <dd>This indicates the installation operation and installs one or more
220 dynamically shared objects into the server's <var>modules</var>
223 <dt><code>-a</code></dt>
224 <dd>This activates the module by automatically adding a corresponding
225 <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> line to Apache's
226 <code>httpd.conf</code> configuration file, or by enabling it if it
229 <dt><code>-A</code></dt>
230 <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
231 sign (<code>#</code>), <em>i.e.</em>, the module is just prepared for
232 later activation but initially disabled.</dd>
234 <dt><code>-e</code></dt>
235 <dd>This indicates the editing operation, which can be used with the
236 <code>-a</code> and <code>-A</code> options similarly to the
237 <code>-i</code> operation to edit Apache's <code>httpd.conf</code>
238 configuration file without attempting to install the module.</dd>
241 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
242 <div class="section">
243 <h2><a name="examples" id="examples">Examples</a></h2>
244 <p>Assume you have an Apache module named <code>mod_foo.c</code> available
245 which should extend Apache's server functionality. To accomplish this you
246 first have to compile the C source into a shared object suitable for loading
247 into the Apache server under runtime via the following command:</p>
249 <div class="example"><p><code>
250 $ apxs -c mod_foo.c<br />
251 gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c<br />
252 ld -Bshareable -o mod_foo.so mod_foo.o<br />
256 <p>Then you have to update the Apache configuration by making sure a
257 <code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> directive is present to
258 load this shared object. To simplify this step <code>apxs</code> provides
259 an automatic way to install the shared object in its "modules" directory
260 and updating the <code>httpd.conf</code> file accordingly. This can be
261 achieved by running:</p>
263 <div class="example"><p><code>
264 $ apxs -i -a mod_foo.c<br />
265 cp mod_foo.so /path/to/apache/modules/mod_foo.so<br />
266 chmod 755 /path/to/apache/modules/mod_foo.so<br />
267 [activating module `foo' in /path/to/apache/etc/httpd.conf]<br />
271 <p>This way a line named</p>
273 <div class="example"><p><code>
274 LoadModule foo_module modules/mod_foo.so
277 <p>is added to the configuration file if still not present. If you want to
278 have this disabled per default use the <code>-A</code> option,
281 <div class="example"><p><code>
282 $ apxs -i -A mod_foo.c
285 <p>For a quick test of the apxs mechanism you can create a sample Apache
286 module template plus a corresponding Makefile via:</p>
288 <div class="example"><p><code>
289 $ apxs -g -n foo<br />
290 Creating [DIR] foo<br />
291 Creating [FILE] foo/Makefile<br />
292 Creating [FILE] foo/mod_foo.c<br />
296 <p>Then you can immediately compile this sample module into a shared object
297 and load it into the Apache server:</p>
299 <div class="example"><p><code>
301 $ make all reload<br />
302 apxs -c mod_foo.c<br />
303 gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c<br />
304 ld -Bshareable -o mod_foo.so mod_foo.o<br />
305 apxs -i -a -n "foo" mod_foo.so<br />
306 cp mod_foo.so /path/to/apache/modules/mod_foo.so<br />
307 chmod 755 /path/to/apache/modules/mod_foo.so<br />
308 [activating module `foo' in /path/to/apache/etc/httpd.conf]<br />
309 apachectl restart<br />
310 /path/to/apache/sbin/apachectl restart: httpd not running, trying to start<br />
311 [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module<br />
312 /path/to/apache/sbin/apachectl restart: httpd started<br />
316 <p>You can even use <code>apxs</code> to compile complex modules outside the
317 Apache source tree, like PHP3:</p>
319 <div class="example"><p><code>
321 $ ./configure --with-shared-apache=../apache-1.3<br />
322 $ apxs -c -o libphp3.so mod_php3.c libmodphp3-so.a<br />
323 gcc -fpic -DSHARED_MODULE -I/tmp/apache/include -c mod_php3.c<br />
324 ld -Bshareable -o libphp3.so mod_php3.o libmodphp3-so.a<br />
328 <p>because <code>apxs</code> automatically recognized C source files and
329 object files. Only C source files are compiled while remaining object
330 files are used for the linking phase.</p>
332 <div class="bottomlang">
333 <p><span>Available Languages: </span><a href="../en/programs/apxs.html" title="English"> en </a> |
334 <a href="../ko/programs/apxs.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
335 <a href="../tr/programs/apxs.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p>
336 </div><div id="footer">
337 <p class="apache">Copyright 2009 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
338 <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>