1APXS(8) apxs APXS(8)
2
3
4
6 apxs - APache eXtenSion tool
7
8
10 apxs -g [ -S name=value ] -n modname
11
12
13 apxs -q [ -S name=value ] query ...
14
15
16 apxs -c [ -S name=value ] [ -o dsofile ] [ -I incdir ] [ -D name=value
17 ] [ -L libdir ] [ -l libname ] [ -Wc,compiler-flags ] [ -Wl,linker-
18 flags ] files ...
19
20
21 apxs -i [ -S name=value ] [ -n modname ] [ -a ] [ -A ] dso-file ...
22
23
24 apxs -e [ -S name=value ] [ -n modname ] [ -a ] [ -A ] dso-file ...
25
26
27
29 apxs is a tool for building and installing extension modules for the
30 Apache HyperText Transfer Protocol (HTTP) server. This is achieved by
31 building a dynamic shared object (DSO) from one or more source or
32 object files which then can be loaded into the Apache server under run‐
33 time via the LoadModule directive from mod_so.
34
35
36 So to use this extension mechanism your platform has to support the DSO
37 feature and your Apache httpd binary has to be built with the mod_so
38 module. The apxs tool automatically complains if this is not the case.
39 You can check this yourself by manually running the command
40
41
42 $ httpd -l
43
44
45
46 The module mod_so should be part of the displayed list. If these
47 requirements are fulfilled you can easily extend your Apache server's
48 functionality by installing your own modules with the DSO mechanism by
49 the help of this apxs tool:
50
51
52 $ apxs -i -a -c mod_foo.c
53 gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c
54 ld -Bshareable -o mod_foo.so mod_foo.o
55 cp mod_foo.so /path/to/apache/modules/mod_foo.so
56 chmod 755 /path/to/apache/modules/mod_foo.so
57 [activating module `foo' in /path/to/apache/etc/httpd.conf]
58 $ apachectl restart
59 /path/to/apache/sbin/apachectl restart: httpd not running, trying to start
60 [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
61 /path/to/apache/sbin/apachectl restart: httpd started
62 $ _
63
64
65
66 The arguments files can be any C source file (.c), a object file (.o)
67 or even a library archive (.a). The apxs tool automatically recognizes
68 these extensions and automatically used the C source files for compila‐
69 tion while just using the object and archive files for the linking
70 phase. But when using such pre-compiled objects make sure they are com‐
71 piled for position independent code (PIC) to be able to use them for a
72 dynamically loaded shared object. For instance with GCC you always just
73 have to use -fpic. For other C compilers consult its manual page or at
74 watch for the flags apxs uses to compile the object files.
75
76
77 For more details about DSO support in Apache read the documentation of
78 mod_so or perhaps even read the src/modules/standard/mod_so.c source
79 file.
80
81
82
84 Common Options
85 -n modname
86 This explicitly sets the module name for the -i (install) and -g
87 (template generation) option. Use this to explicitly specify the
88 module name. For option -g this is required, for option -i the
89 apxs tool tries to determine the name from the source or (as a
90 fallback) at least by guessing it from the filename.
91
92
93 Query Options
94 -q Performs a query for apxs's knowledge about certain settings.
95 The query parameters can be one or more of the following
96 strings: CC, CFLAGS, CFLAGS_SHLIB, INCLUDEDIR, LD_SHLIB,
97 LDFLAGS_SHLIB, LIBEXECDIR, LIBS_SHLIB, SBINDIR, SYSCONFDIR, TAR‐
98 GET. .PP Use this for manually determining settings. For
99 instance use INC=-I`apxs -q INCLUDEDIR` .PP inside your own
100 Makefiles if you need manual access to Apache's C header files.
101
102
103 Configuration Options
104 -S name=value
105 This option changes the apxs settings described above.
106
107
108 Template Generation Options
109 -g This generates a subdirectory name (see option -n) and there two
110 files: A sample module source file named mod_name.c which can be
111 used as a template for creating your own modules or as a quick
112 start for playing with the apxs mechanism. And a corresponding
113 Makefile for even easier build and installing of this module.
114
115
116 DSO Compilation Options
117 -c This indicates the compilation operation. It first compiles the
118 C source files (.c) of files into corresponding object files
119 (.o) and then builds a dynamically shared object in dsofile by
120 linking these object files plus the remaining object files (.o
121 and .a) of files. If no -o option is specified the output file
122 is guessed from the first filename in files and thus usually
123 defaults to mod_name.so.
124
125 -o dsofile
126 Explicitly specifies the filename of the created dynamically
127 shared object. If not specified and the name cannot be guessed
128 from the files list, the fallback name mod_unknown.so is used.
129
130 -D name=value
131 This option is directly passed through to the compilation com‐
132 mand(s). Use this to add your own defines to the build process.
133
134 -I incdir
135 This option is directly passed through to the compilation com‐
136 mand(s). Use this to add your own include directories to search
137 to the build process.
138
139 -L libdir
140 This option is directly passed through to the linker command.
141 Use this to add your own library directories to search to the
142 build process.
143
144 -l libname
145 This option is directly passed through to the linker command.
146 Use this to add your own libraries to search to the build
147 process.
148
149 -Wc,compiler-flags
150 This option passes compiler-flags as additional flags to the
151 libtool --mode=compile command. Use this to add local compiler-
152 specific options.
153
154 -Wl,linker-flags
155 This option passes linker-flags as additional flags to the
156 libtool --mode=link command. Use this to add local linker-spe‐
157 cific options.
158
159
160 DSO Installation and Configuration Options
161 -i This indicates the installation operation and installs one or
162 more dynamically shared objects into the server's modules direc‐
163 tory.
164
165 -a This activates the module by automatically adding a correspond‐
166 ing LoadModule line to Apache's httpd.conf configuration file,
167 or by enabling it if it already exists.
168
169 -A Same as option -a but the created LoadModule directive is pre‐
170 fixed with a hash sign (#), i.e., the module is just prepared
171 for later activation but initially disabled.
172
173 -e This indicates the editing operation, which can be used with the
174 -a and -A options similarly to the -i operation to edit Apache's
175 httpd.conf configuration file without attempting to install the
176 module.
177
178
180 Assume you have an Apache module named mod_foo.c available which should
181 extend Apache's server functionality. To accomplish this you first have
182 to compile the C source into a shared object suitable for loading into
183 the Apache server under runtime via the following command:
184
185
186 $ apxs -c mod_foo.c
187 /path/to/libtool --mode=compile gcc ... -c mod_foo.c
188 /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
189 $ _
190
191
192
193 Then you have to update the Apache configuration by making sure a Load‐
194 Module directive is present to load this shared object. To simplify
195 this step apxs provides an automatic way to install the shared object
196 in its "modules" directory and updating the httpd.conf file accord‐
197 ingly. This can be achieved by running:
198
199
200 $ apxs -i -a mod_foo.la
201 /path/to/instdso.sh mod_foo.la /path/to/apache/modules
202 /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
203 ...
204 chmod 755 /path/to/apache/modules/mod_foo.so
205 [activating module `foo' in /path/to/apache/conf/httpd.conf]
206 $ _
207
208
209
210 This way a line named
211
212
213 LoadModule foo_module modules/mod_foo.so
214
215
216
217 is added to the configuration file if still not present. If you want to
218 have this disabled per default use the -A option, i.e.
219
220
221 $ apxs -i -A mod_foo.c
222
223
224
225 For a quick test of the apxs mechanism you can create a sample Apache
226 module template plus a corresponding Makefile via:
227
228
229 $ apxs -g -n foo
230 Creating [DIR] foo
231 Creating [FILE] foo/Makefile
232 Creating [FILE] foo/modules.mk
233 Creating [FILE] foo/mod_foo.c
234 Creating [FILE] foo/.deps
235 $ _
236
237
238
239 Then you can immediately compile this sample module into a shared
240 object and load it into the Apache server:
241
242
243 $ cd foo
244 $ make all reload
245 apxs -c mod_foo.c
246 /path/to/libtool --mode=compile gcc ... -c mod_foo.c
247 /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
248 apxs -i -a -n "foo" mod_foo.la
249 /path/to/instdso.sh mod_foo.la /path/to/apache/modules
250 /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
251 ...
252 chmod 755 /path/to/apache/modules/mod_foo.so
253 [activating module `foo' in /path/to/apache/conf/httpd.conf]
254 apachectl restart
255 /path/to/apache/sbin/apachectl restart: httpd not running, trying to start
256 [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
257 /path/to/apache/sbin/apachectl restart: httpd started
258 $ _
259
260
261
262
263
264Apache HTTP Server 2004-10-01 APXS(8)