]> granicus.if.org Git - apache/blob - docs/manual/programs/apxs.html.en
update transformation
[apache] / docs / manual / programs / apxs.html.en
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
7       -->
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="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
18 <div id="path">
19 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs-project/">Documentation</a> &gt; <a href="../">Version 2.1</a> &gt; <a href="./">Programs</a></div><div id="page-content"><div id="preamble"><h1>apxs - APache eXtenSion tool</h1>
20 <div class="toplang">
21 <p><span>Available Languages: </span><a href="../en/programs/apxs.html" title="English">&nbsp;en&nbsp;</a></p>
22 </div>
23
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>
30
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>
36
37     <div class="example"><p><code>
38       $ httpd -l
39     </code></p></div>
40
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>
45
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 />
57       $ _
58     </code></p></div>
59
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
69     object files.</p>
70
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>
74 </div>
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>
80 <div class="section">
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>
85
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>
89
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>
100
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>
107
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>
118       <dl>
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
125       filename.</dd>
126       </dl>
127     
128
129     <h3><a name="options.query" id="options.query">Query Options</a></h3>
130       <dl>
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>,
138       <code>TARGET</code>.
139
140       <p>Use this for manually determining settings. For instance use</p>
141       <div class="example"><p><code>
142         INC=-I`apxs -q INCLUDEDIR`
143       </code></p></div>
144
145       <p>inside your own Makefiles if you need manual access to Apache's C
146       header files.</p></dd>
147       </dl>
148     
149
150     <h3><a name="options.conf" id="options.conf">Configuration Options</a></h3>
151       <dl>
152       <dt><code>-S <var>name</var>=<var>value</var></code></dt>
153       <dd>This option changes the apxs settings described above.</dd>
154       </dl>
155     
156
157     <h3><a name="options.template" id="options.template">Template Generation Options</a></h3>
158       <dl>
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>
166       </dl>
167     
168
169     <h3><a name="options.dso" id="options.dso">DSO Compilation Options</a></h3>
170       <dl>
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>
179
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
184       used.</dd>
185
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>
189
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
193       process.</dd>
194
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>
198
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>
202
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>
206
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>
210       </dl>
211     
212
213     <h3><a name="options.dsoinstall" id="options.dsoinstall">DSO Installation and Configuration Options</a></h3>
214     
215       <dl>
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>
219       directory.</dd>
220
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
225       already exists.</dd>
226
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>
231
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>
237       </dl>
238     
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>
246
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 />
251       $ _
252     </code></p></div>
253
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>
260
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 />
266       $ _
267     </code></p></div>
268
269     <p>This way a line named</p>
270
271     <div class="example"><p><code>
272       LoadModule foo_module modules/mod_foo.so
273     </code></p></div>
274
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,
277     <em>i.e.</em></p>
278
279     <div class="example"><p><code>
280       $ apxs -i -A mod_foo.c
281     </code></p></div>
282
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>
285
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 />
291       $ _
292     </code></p></div>
293
294     <p>Then you can immediately compile this sample module into a shared object
295     and load it into the Apache server:</p>
296
297     <div class="example"><p><code>
298       $ cd foo<br />
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 />
311       $ _
312     </code></p></div>
313
314     <p>You can even use <code>apxs</code> to compile complex modules outside the
315     Apache source tree, like PHP3:</p>
316
317     <div class="example"><p><code>
318       $ cd php3<br />
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 />
323       $ _
324     </code></p></div>
325
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>
329 </div></div>
330 <div class="bottomlang">
331 <p><span>Available Languages: </span><a href="../en/programs/apxs.html" title="English">&nbsp;en&nbsp;</a></p>
332 </div><div id="footer">
333 <p class="apache">Copyright 1999-2004 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>
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>
335 </body></html>