APXS(1)
π apxs β APache eXtenSion tool π
okay so bestie, welcome to the apxs(1) manual page β¨ this is the whole thing, every flag, every vibe, no skips. buckle up π
πΈ NAME πΈ
apxs β APache eXtenSion tool π
π¦ SYNOPSIS π¦
apxs -g [ -S name=value ] -n modname
apxs -q [ -v ] [ -S name=value ] query ...
apxs -c [ -S name=value ] [ -o dsofile ] [ -I incdir ] [ -D name=value ]
[ -L libdir ] [ -l libname ] [ -Wc,compiler-flags ] [ -Wl,linker-flags ]
files ...
apxs -i [ -S name=value ] [ -n modname ] [ -a ] [ -A ] dso-file ...
apxs -e [ -S name=value ] [ -n modname ] [ -a ] [ -A ] dso-file ...
β¨ SUMMARY β¨
so like, apxs is the tool for building and installing extension modules for the Apache HyperText Transfer Protocol (HTTP) server π it does this by building a dynamic shared object (DSO) out of one or more source or object files, and then that DSO can get loaded into the Apache server at runtime via the LoadModule directive from mod_so π«Ά
so for this extension mechanism to even work, your platform has to support the DSO feature, and your Apache httpd binary has to be built with the mod_so module. the apxs tool automatically complains if that's not the case π you can check it yourself by manually running:
$ httpd -l
mod_so should be part of the displayed list π if all those requirements are fulfilled, you can easily extend your Apache server's functionality by installing your own modules with the DSO mechanism, with the help of this apxs tool:
$ apxs -i -a -c mod_foo.c
gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c
ld -Bshareable -o mod_foo.so mod_foo.o
cp mod_foo.so /path/to/apache/modules/mod_foo.so
chmod 755 /path/to/apache/modules/mod_foo.so
[activating module `foo' in /path/to/apache/etc/httpd.conf]
$ apachectl restart
/path/to/apache/sbin/apachectl restart: httpd not running, trying to start
[Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
/path/to/apache/sbin/apachectl restart: httpd started
$ _
the arguments files can be any C source file (.c), an object file (.o), or even a library archive (.a) π the apxs tool automatically recognizes those extensions and automatically uses the C source files for compilation, while just using the object and archive files for the linking phase. but when you're using pre-compiled objects like that, make sure they're compiled for position independent code (PIC) so they can actually be used for a dynamically loaded shared object π for instance with GCC you always just have to use -fpic. for other C compilers, consult its manual page, or keep an eye out for the flags apxs uses to compile the object files π
for more details about DSO support in Apache, read the documentation of mod_so, or maybe even read the src/modules/standard/mod_so.c source file π
π OPTIONS π
π Common Options π
-nmodname β this explicitly sets the module name for the-i(install) and-g(template generation) option. use it to explicitly specify the module name. for option-gthis is required, and for option-itheapxstool tries to determine the name from the source, or (as a fallback) at least by guessing it from the filename π
π Query Options π
-qβ performs a query for variables and environment settings used to build httpd. when invoked without query parameters, it prints all known variables and their values. the optional-vparameter formats the list output π
use this to manually determine the settings used to build the httpd that will load your module. for instance use INC=-I\apxs -q INCLUDEDIR``
inside your own Makefiles if you need manual access to Apache's C header files π
βοΈ Configuration Options βοΈ
-Sname=value β this option changes theapxssettings described above β¨
π§ Template Generation Options π§
-gβ this generates a subdirectory name (see option-n) and there, two files: a sample module source file namedmod_name.cwhich can be used as a template for creating your own modules, or as a quick start for playing with theapxsmechanism π and a correspondingMakefilefor even easier building and installing of this module π
π₯ DSO Compilation Options π₯
-cβ this indicates the compilation operation. it first compiles the C source files (.c) of files into corresponding object files (.o), and then builds a dynamically shared object in dsofile by linking those object files plus the remaining object files (.oand.a) of files. if no-ooption is specified, the output file is guessed from the first filename in files, and thus usually defaults tomod_name.soβ-odsofile β explicitly specifies the filename of the created dynamically shared object. if it's not specified and the name can't be guessed from the files list, the fallback namemod_unknown.sois used π-Dname=value β this option is directly passed through to the compilation command(s). use this to add your own defines to the build process π οΈ-Iincdir β this option is directly passed through to the compilation command(s). use this to add your own include directories to search to the build process π-Llibdir β this option is directly passed through to the linker command. use this to add your own library directories to search to the build process π-llibname β this option is directly passed through to the linker command. use this to add your own libraries to search to the build process π-Wc,compiler-flags β this option passes compiler-flags as additional flags to thelibtool --mode=compilecommand. use this to add local compiler-specific options π©βπ»-Wl,linker-flags β this option passes linker-flags as additional flags to thelibtool --mode=linkcommand. use this to add local linker-specific options π§-pβ this option causesapxsto link against theapr/apr-utillibraries. this is useful when compiling helper programs that use theapr/apr-utillibraries πΈ
π DSO Installation and Configuration Options π
-iβ this indicates the installation operation, and installs one or more dynamically shared objects into the server's modules directory π¦-aβ this activates the module by automatically adding a correspondingLoadModuleline to Apache'shttpd.confconfiguration file, or by enabling it if it already exists β-Aβ same as option-a, but the createdLoadModuledirective is prefixed with a hash sign (#), i.e., the module is just prepared for later activation but initially disabled π-eβ this indicates the editing operation, which can be used with the-aand-Aoptions similarly to the-ioperation, to edit Apache'shttpd.confconfiguration file without attempting to install the module βοΈ
π EXAMPLES π
okay so imagine you have an Apache module named mod_foo.c available, and it should extend Apache's server functionality. to accomplish this, you first have to compile the C source into a shared object suitable for loading into the Apache server at runtime, via the following command:
$ apxs -c mod_foo.c
/path/to/libtool --mode=compile gcc ... -c mod_foo.c
/path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
$ _
then you have to update the Apache configuration by making sure a LoadModule directive is present to load this shared object. to simplify this step, apxs provides an automatic way to install the shared object in its "modules" directory and update the httpd.conf file accordingly. this can be achieved by running:
$ apxs -i -a mod_foo.la
/path/to/instdso.sh mod_foo.la /path/to/apache/modules
/path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
...
chmod 755 /path/to/apache/modules/mod_foo.so
[activating module `foo' in /path/to/apache/conf/httpd.conf]
$ _
this way a line named
LoadModule foo_module modules/mod_foo.so
is added to the configuration file if it's still not present π if you want it disabled per default instead, use the -A option, i.e.
$ apxs -i -A mod_foo.c
for a quick test of the apxs mechanism you can create a sample Apache module template plus a corresponding Makefile via:
$ apxs -g -n foo
Creating [DIR] foo
Creating [FILE] foo/Makefile
Creating [FILE] foo/modules.mk
Creating [FILE] foo/mod_foo.c
Creating [FILE] foo/.deps
$ _
then you can immediately compile this sample module into a shared object and load it into the Apache server:
$ cd foo
$ make all reload
apxs -c mod_foo.c
/path/to/libtool --mode=compile gcc ... -c mod_foo.c
/path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
apxs -i -a -n "foo" mod_foo.la
/path/to/instdso.sh mod_foo.la /path/to/apache/modules
/path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
...
chmod 755 /path/to/apache/modules/mod_foo.so
[activating module `foo' in /path/to/apache/conf/httpd.conf]
apachectl restart
/path/to/apache/sbin/apachectl restart: httpd not running, trying to start
[Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
/path/to/apache/sbin/apachectl restart: httpd started
$ _
and that's the whole page bestie, no cap π go build something iconic π«Ά
β¨ that's a wrap on APXS(1) from the Apache HTTP Server, dated 2026-04-30 β¨ mwah, slay, periodt π
πΈ
π¦ where this page comes from
- debian bookworm: apache2-dev 2.4.68-1~deb12u1 Β· Apache-2.0
- debian trixie: apache2-dev 2.4.68-1~deb13u1 Β· Apache-2.0
- debian trixie: apache2-dev 2.4.69-1~deb13u1 Β· Apache-2.0
- ubuntu stonking: apache2-dev 2.4.68-1ubuntu4 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms