MirOS Manual: apxs(8)

APXS(8)                  BSD System Manager's Manual                   APXS(8)

NAME

     apxs - APache eXtenSion tool

SYNOPSIS

     apxs -c [-D variable[=value]] [-I incdir] [-L libdir] [-l libname]
             [-o dsofile] [-S variable=value] [-Wc,compiler-flags]
             [-Wl,linker-flags] file ...
     apxs -e [-Aa] [-n name] [-S variable=value] dsofile ...
     apxs -g [-S variable=value] -n name
     apxs -i [-Aa] [-n name] [-S variable=value] dsofile ...
     apxs -q [-S variable=value] query ...

DESCRIPTION

     apxs is a tool for building and installing extension modules for the Hy-
     perText Transfer Protocol (HTTP) server, httpd(8). This is achieved by
     building a Dynamic Shared Object (DSO) from one or more source or object
     files which can then be loaded into httpd at runtime via the LoadModule
     directive from mod_so. To use this extension mechanism, your platform has
     to support the DSO feature and the httpd binary has to be built with the
     mod_so module. The apxs tool automatically complains if this is not the
     case. Check by manually running the following command:

           $ httpd -l

     The module mod_so should be part of the displayed list. If these require-
     ments are fulfilled, httpd's functionality can be extended by installing
     modules with the DSO mechanism, with the help of the apxs tool:

           # apxs -i -a -c mod_foo.c
           gcc -O2 -pipe -DDEV_RANDOM=/dev/arandom -DMOD_SSL=208116 -DEAPI -DUSE_SETUSERCONTEXT -fPIC -DSHARED_MODULE -I/usr/libexec/httpd/include  -c mod_foo.c
           [activating module `foo' in /var/www/conf/httpd.conf]
           cp mod_foo.so /usr/libexec/httpd/modules/mod_foo.so
           chmod 755 /usr/libexec/httpd/modules/mod_foo.so
           cp /var/www/conf/httpd.conf /var/www/conf/httpd.conf.bak
           cp /var/www/conf/httpd.conf.new /var/www/conf/httpd.conf
           rm /var/www/conf/httpd.conf.new
           # kill $(</var/www/logs/httpd.pid)
           # httpd [flags]

     The argument file can be any C source file (.c), an object file (.o), or
     even a library archive (.a). The apxs tool automatically recognizes these
     extensions and automatically uses the C source files for compilation,
     whereas it just uses the object and archive files for the linking phase.
     But when using such pre-compiled objects, make sure they are compiled for
     Position Independent Code (PIC) to be able to use them for a DSO. For in-
     stance, with gcc(1) just use -fpic. For other C compilers, please consult
     their manual pages or watch for the flags apxs uses to compile the object
     files.

     For more details about DSO support in httpd, first read the background
     information about DSO in htdocs/manual/dso.html, then read the documenta-
     tion of mod_so.

     The options are as follows:

     -A      Same as the -a option but the created LoadModule directive is
             prefixed with a hash sign (#), i.e. the module is just prepared
             for later activation but initially disabled.

     -a      This activates the module by automatically adding a corresponding
             LoadModule line to httpd's httpd.conf configuration file, or by
             enabling it if it already exists.

     -c      Compile. This option first compiles the C source files (.c) of
             file ... into corresponding object files (.o) and then builds a
             DSO in dsofile by linking these object files plus the remaining
             object files (.o and .a) of file ... If no -o option is speci-
             fied, the output file is guessed from the first filename in file
             ... and thus usually defaults to mod_name.so

     -D variable[=value]
             This option is directly passed through to the compilation
             command(s). Use this to add your own defines to the build pro-
             cess.

     -e      Edit. This option can be used with the -a and -A options to edit
             the configuration file, /var/www/conf/httpd.conf, without at-
             tempting to install the module.

     -g      Template generation. This option generates a subdirectory name
             (see the -n option) and two files: a sample module source file
             named mod_name.c, which can be used as a template for creating
             your own modules or as a quick start for playing with the apxs
             mechanism, and a corresponding Makefile for even easier building
             and installing of this module.

     -I incdir
             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.

     -i      Install. This option installs one or more DSOs into the server's
             libexec directory.

     -L libdir
             This option is directly passed through to the linker command. Use
             this to add your own library directories to search to the build
             process.

     -l libname
             This option is directly passed through to the linker command. Use
             this to add your own libraries to search to the build process.

     -n name
             This explicitly sets the module name for the -i (install) and -g
             (template generation) option. Use this to explicitly specify the
             module name. For option -g this is required; for option -i, apxs
             tries to determine the name from the source or (as a fallback) at
             least by guessing it from the filename.

     -o dsofile
             Explicitly specifies the filename of the created DSO file. If not
             specified and the name cannot be guessed from the file ... list,
             the fallback name mod_unknown.so is used.

     -q      Query. This option performs a query for apxs's knowledge about
             certain settings. The query parameters can be one or more of the
             following variable names:

                   CC              TARGET
                   CFLAGS          SBINDIR
                   CFLAGS_SHLIB    INCLUDEDIR
                   LD_SHLIB        LIBEXECDIR
                   LDFLAGS_SHLIB   SYSCONFDIR
                   LIBS_SHLIB      PREFIX

             Use this for manually determining settings. For instance, use the
             following inside your own Makefiles if you need manual access to
             httpd's C header files:

                   INC=-I`apxs -q INCLUDEDIR`

     -S variable=value
             This option changes the apxs settings described above.

     -Wc,compiler-flags
             This option passes compiler-flags as additional flags to the com-
             piler command. Use this to add local compiler-specific options.
             This option may be specified multiple times in order to pass mul-
             tiple flags.

     -Wl,linker-flags
             This option passes linker-flags as additional flags to the linker
             command. Use this to add local linker-specific options. This op-
             tion may be specified multiple times in order to pass multiple
             flags.

EXAMPLES

     Assume you have a module named "mod_foo.c" available which should extend
     httpd's functionality. To accomplish this, first compile the C source
     into a DSO suitable for loading into httpd at runtime via the following
     command:

           # apxs -c mod_foo.c
           gcc -O2 -pipe -DDEV_RANDOM=/dev/arandom -DMOD_SSL=208116 -DEAPI -DUSE_SETUSERCONTEXT -fPIC -DSHARED_MODULE -I/usr/libexec/httpd/include  -c mod_foo.c
           gcc -shared -fPIC -DSHARED_MODULE -o mod_foo.so mod_foo.o

     Then a LoadModule directive has to be added to httpd's configuration file
     to load the DSO. To simplify this step, apxs provides an automatic way to
     install the DSO in the "libexec" directory and update the httpd.conf file
     accordingly. This can be achieved by running the following:

           $ apxs -i -a mod_foo.so
           [activating module `foo' in /var/www/conf/httpd.conf]
           cp mod_foo.so /usr/libexec/httpd/modules/mod_foo.so
           chmod 755 /usr/libexec/httpd/modules/mod_foo.so
           cp /var/www/conf/httpd.conf /var/www/conf/httpd.conf.bak
           cp /var/www/conf/httpd.conf.new /var/www/conf/httpd.conf
           rm /var/www/conf/httpd.conf.new

     This way a line such as the following is added to the configuration file:

           LoadModule foo_module /usr/libexec/httpd/modules/mod_foo.so

     If you want the module added to the configuration file without it being
     enabled, use the -A option instead:

           $ apxs -i -A mod_foo.so

     For a quick test of the apxs mechanism, create a sample module template
     plus a corresponding Makefile via:

           # apxs -g -n foo
           Creating [DIR]  foo
           Creating [FILE] foo/Makefile
           Creating [FILE] foo/mod_foo.c

     The sample module can then be immediately compiled into a DSO and loaded
     into the httpd server:

           $ cd foo
           $ make all reload
           apxs -c    mod_foo.c
           gcc -O2 -pipe -DDEV_RANDOM=/dev/arandom -DMOD_SSL=208116 -DEAPI -DUSE_SETUSERCONTEXT -fPIC -DSHARED_MODULE -I/usr/libexec/httpd/include  -c mod_foo.c
           gcc -shared -fPIC -DSHARED_MODULE -o mod_foo.so mod_foo.o
           apxs -i -a -n 'foo' mod_foo.so
           [activating module `foo' in /var/www/conf/httpd.conf]
           cp mod_foo.so /usr/libexec/httpd/modules/mod_foo.so
           chmod 755 /usr/libexec/httpd/modules/mod_foo.so
           cp /var/www/conf/httpd.conf /var/www/conf/httpd.conf.bak
           cp /var/www/conf/httpd.conf.new /var/www/conf/httpd.conf
           rm /var/www/conf/httpd.conf.new
           kill $(</var/www/logs/httpd.pid)
           httpd [flags]

     apxs can even be used to compile complex modules outside the httpd source
     tree, like PHP3, because apxs automatically recognizes C source files and
     object files.

           $ cd php3
           $ ./configure --with-shared-apache=../httpd
           $ apxs -c -o libphp3.so mod_php3.c libmodphp3-so.a
           gcc -fpic -DSHARED_MODULE -I/tmp/httpd/include  -c mod_php3.c
           ld -Bshareable -o libphp3.so mod_php3.o libmodphp3-so.a

     Only C source files are compiled, while remaining object files are used
     for the linking phase.

SEE ALSO

     gcc(1), httpd(8)

MirOS BSD #10-current           March 19, 2008                               3

Generated on 2014-04-02 20:57:59 by $MirOS: src/scripts/roff2htm,v 1.79 2014/02/10 00:36:11 tg Exp $

These manual pages and other documentation are copyrighted by their respective writers; their source is available at our CVSweb, AnonCVS, and other mirrors. The rest is Copyright © 2002‒2014 The MirOS Project, Germany.
This product includes material provided by Thorsten Glaser.

This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report – diffs preferred.