Configuring and Managing MPE/iX Internet Services (July 2001)

Chapter 9 175
Apache for MPE/iX
Major Components
Creating Apache Modules
DSOs can be written in either the C programming language or in the
Perl scripting language. DSOs written in C must be compiled on
MPE/iX. Those written in Perl require a Perl interpreter to be
embedded into Apache. This embedded Perl interpreter is provided by
the mod_perl module. Mod_perl is part of the HP WebWise MPE/iX
Secure Web Server product, version 2 or later, but is not part of
standard Apache on MPE/iX. Since Perl modules cannot currently be
used with standard Apache, this manual describes only how to create
Apache DSOs in C.
Two ways that Apache module’s can be created are:
1. From a template, such as mod_example.c, or from an existing
module.
2. With the apxs utility.
A sample module, mod_hw, will be used to illustrate these two
methods for creating a DSO module in C. The code for mod_hw is listed
in the section “Sample Module Code (mod_hw)” and the mod_hw
structure is shown in Figure 9-1.
Figure 9-1 Sample Module (mod_hw)
The mod_hw consists of two source files, mod_hw.c and hw.c. The file
mod_hw.c contains the module structure and makes an external
function call to pow() in the math library (/lib/libm). The mod_hw.c
also makes an external function call to helloworld(), defined in hw.c.
The output of mod_hw prints Hello World and also prints the result
of raising 12 to the power of 2.
This module demonstrates how to build a DSO that calls external
functions. Using mod_hw as an example, you will see how to compile
and link an Apache module that calls an external function from an
object file and calls an external function from a system library.
Note that modules are named mod_xxx.so by convention. To follow
this convention, the sample module is called mod_hw.so.
libm mod_hw.c hw.c
Function pow()
pow()
helloworld()
Function
helloworld()