1APXS(1)                              apxs                              APXS(1)
2
3
4

NAME

6       apxs - APache eXtenSion tool
7
8

SYNOPSIS

10       apxs -g [ -S name=value ] -n modname
11
12
13       apxs -q [ -v ] [ -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

SUMMARY

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

OPTIONS

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 variables and environment settings used to
95              build httpd. When invoked without query  parameters,  it  prints
96              all  known variables and their values. The optional -v parameter
97              formats the list output. .PP Use this to manually determine set‐
98              tings  used  to  build the httpd that will load your module. 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       -p     This  option  causes  apxs  to  link  against  the  apr/apr-util
160              libraries.  This  is  useful when compiling helper programs that
161              use the apr/apr-util libraries.
162
163
164   DSO Installation and Configuration Options
165       -i     This indicates the installation operation and  installs  one  or
166              more dynamically shared objects into the server's modules direc‐
167              tory.
168
169       -a     This activates the module by automatically adding a  correspond‐
170              ing  LoadModule  line to Apache's httpd.conf configuration file,
171              or by enabling it if it already exists.
172
173       -A     Same as option -a but the created LoadModule directive  is  pre‐
174              fixed  with  a  hash sign (#), i.e., the module is just prepared
175              for later activation but initially disabled.
176
177       -e     This indicates the editing operation, which can be used with the
178              -a and -A options similarly to the -i operation to edit Apache's
179              httpd.conf configuration file without attempting to install  the
180              module.
181
182

EXAMPLES

184       Assume you have an Apache module named mod_foo.c available which should
185       extend Apache's server functionality. To accomplish this you first have
186       to  compile the C source into a shared object suitable for loading into
187       the Apache server under runtime via the following command:
188
189
190             $ apxs -c mod_foo.c
191             /path/to/libtool --mode=compile gcc ... -c mod_foo.c
192             /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
193             $ _
194
195
196
197       Then you have to update the Apache configuration by making sure a Load‐
198       Module  directive  is  present  to load this shared object. To simplify
199       this step apxs provides an automatic way to install the  shared  object
200       in  its  "modules"  directory  and updating the httpd.conf file accord‐
201       ingly. This can be achieved by running:
202
203
204             $ apxs -i -a mod_foo.la
205             /path/to/instdso.sh mod_foo.la /path/to/apache/modules
206             /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
207             ...
208             chmod 755 /path/to/apache/modules/mod_foo.so
209             [activating module `foo' in /path/to/apache/conf/httpd.conf]
210             $ _
211
212
213
214       This way a line named
215
216
217             LoadModule foo_module modules/mod_foo.so
218
219
220
221       is added to the configuration file if still not present. If you want to
222       have this disabled per default use the -A option, i.e.
223
224
225             $ apxs -i -A mod_foo.c
226
227
228
229       For  a  quick test of the apxs mechanism you can create a sample Apache
230       module template plus a corresponding Makefile via:
231
232
233             $ apxs -g -n foo
234             Creating [DIR]  foo
235             Creating [FILE] foo/Makefile
236             Creating [FILE] foo/modules.mk
237             Creating [FILE] foo/mod_foo.c
238             Creating [FILE] foo/.deps
239             $ _
240
241
242
243       Then you can immediately compile  this  sample  module  into  a  shared
244       object and load it into the Apache server:
245
246
247             $ cd foo
248             $ make all reload
249             apxs -c mod_foo.c
250             /path/to/libtool --mode=compile gcc ... -c mod_foo.c
251             /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
252             apxs -i -a -n "foo" mod_foo.la
253             /path/to/instdso.sh mod_foo.la /path/to/apache/modules
254             /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
255             ...
256             chmod 755 /path/to/apache/modules/mod_foo.so
257             [activating module `foo' in /path/to/apache/conf/httpd.conf]
258             apachectl restart
259             /path/to/apache/sbin/apachectl restart: httpd not running, trying to start
260             [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
261             /path/to/apache/sbin/apachectl restart: httpd started
262             $ _
263
264
265
266
267
268Apache HTTP Server                2018-07-06                           APXS(1)
Impressum