Setting up third party modules for HTTP Server
This topic provides information about how to set up third party modules for your Web server.
The HTTP Server can extend its functionality in specific areas of your server using modules. For
example, a module could be configured to create a new type of authentication that is not available
with the shipped HTTP Server. The Apache Software Foundation (ASF)
provides basic information for writing
your own modules. Before the module can be used by your HTTP Server, it must be compiled and saved
in the QSYS directory. In addition, the LoadModule directive must be entered in your server configuration file along
with any specific context required information.
As of 5.4, modules must be recompiled with a UTF locale. This creates an environment where locale-dependent C runtime functions assume that string data is encoded in UTF-8. Any hardcoded constants can be encoded in UTF-8 by adding a #pragma convert(1208) statement in the module. Additionally, input data from the client will no longer be converted to EBCDIC but will be passed as-is. Output data sent from the module is not converted either so it must be encoded in ASCII or UTF8 as required. APR and HTTP APIs as of V5R4, expect data in UTF-8. Note that several APIs have additional functions that allow a CCSID to be set to indicate the encoding of the parameters being passed. Conversion functions between UTF-8 and EBCDIC have been added. Be sure to review APIs used by your module to be aware of current changes.
Follow the below directions to compile and use a new module.
1. Save the source code
Save the source code in your QSYS or IFS directory. All objects created from compiling and creating the service program must be placed in the QSYS directory.
2. Compile the source code
Compile the source code using the CRTCMOD command. Before you compile the program, make sure you have the correct programming language compiler installed on your server (the most common programming language used is C). Replace the text in the parenthesis ( ) with your own information.
CRTCMOD MODULE(Destination module name and library for the compiled module object.)
- For ILE C use:
CRTCMOD MODULE(MYLIB/MOD_TEST) SRCSTMF('/mydir/mymodule/source/mod_test.c') DEFINE(AS400 AS400_UTF8) LOCALETYPE(*LOCALEUTF) TERASPACE(*YES) INCDIR('/qibm/proddata/httpa/include') - For C++ use:
CRTCPPMOD MODULE(MYLIB/MOD_TEST) SRCSTMF('/mydir/mymodule/source/mod_test.c') DEFINE(AS400 AS400_UTF8) LOCALETYPE(*LOCALEUTF) TERASPACE(*YES) INCDIR('/qibm/proddata/httpa/include')
Correct any errors found while compiling. Continue to compile the source code until there are no errors. Save the compiled module in the QSYS directory.
3. Create a service program
Create a service program using the CRTSRVPGM command. Replace the text in the parenthesis ( ) with your own information.
CRTSRVPGM SRVPGM(Destination service program name and library.)
MODULE(Module or modules to be built into the service program. Same as CRTCMOD above.)
EXPORT(Name of the data item to be exported.)
BNDSRVPGM(Specifies other service programs needed to bind to when creating the service program.)
The BNDSRVPGM field must have, at a minimum, the following: (QHTTPSVR/QZSRAPR QHTTPSVR/QZSRCORE QHTTPSVR/QZSRXMLP QHTTPSVR/QZSRSDBM ). These values will cover all the HTTP Sever APIs that may be used when building the service program.
4. Add LoadModule to HTTP Server configuration file
See Setting up Apache modules for the steps
you need to perform to add the LoadModule directive.