Configuring and Managing MPE/iX Internet Services
> Chapter 9 Apache for MPE/iXMajor Components |
||||||||||||||||||||||||||||||||||||||||
|
Preparing HP e3000 for Network AccessBefore an HP e3000 can act as a web server, it must be available for network access via TCP/IP:
:run ping.net.sys;info="15.99.200.390" 64 byte(s) from $0F0DC0CF : icmp seq = 11, time = 2 ms 64 byte(s) from $0F0DC0CF : icmp seq = 12, time = 3 ms 64 byte(s) from $0F0DC0CF : icmp seq = 13, time = 2 ms < CONTROL-y > C:\>ping yourserver.com Pinging yourserver.com [15.99.200.390] with 32 bytes of data Reply from 15.99.200.390: bytes=32 time<10ms TTL=199 Reply from 15.99.200.390: bytes=32 time<10ms TTL=199 Reply from 15.99.200.390: bytes=32 time<10ms TTL=199You will also want a domain name. This is a unique identifier such as "yourserver.abc.com" which is used (instead of the IP address) to direct requests from a browser to a web server. Request a domain name from the administrator of the Domain Name Server (DNS) on your network. Configure the web server with one or more Domain Name Servers (DNS). These DNS servers will resolve the system's name into its IP address. To configure, edit RESLVCNF.NET.SYS or edit /etc/resolv.conf (which links to RESLVCNF.NET.SYS):
shell/iX> uname -n YOURSERVER shell/iX > cat /etc/resolv.conf #domain <domain> #nameserver <primary server's IP address> #nameserver <secondary server's IP address> # # domain abc.com nameserver 25.33.100.134 nameserver 25.33.125.172 Configure ApacheThe /APACHE/VUUFF/conf directory contains the Apache configuration files. You will need your own copies of these under the /APACHE/PUB/conf directory. The .sample files are derived from the .default files with modifications for MPE/iX. The installation job sets up links to the /APACHE/VUUFF/conf directory so the following copy commands will get the new versions. Make sure to logon as MGR.APACHE before beginning configuration: :HELLO MGR.APACHE :XEQ SH.HPBIN.SYS -L shell/iX> cd /APACHE/PUB/conf shell/iX> cp mime.types.sample mime.types shell/iX> cp magic.sample magic shell/iX> cp httpd.conf.sample conf shell/iX> cp access.conf.sample access.conf (optional) shell/iX> cp srm.conf.sample srm.conf (optional)The access.conf.sample file and the srm.conf.sample file need not be copied. These files were used in earlier versions of Apache but their content is now included in the httpd.conf file. However, if these files exist, Apache will read and process them after processing the httpd.conf file. Edit httpd.confApache reads the httpd.conf file and the mime.types file at startup (and access.conf and srm.conf if they exist). These configuration files determine how Apache behaves. It is usually not necessary to modify the mime.types file. Edit the httpd.conf file for your own server, you may also wish to change other default values in httpd.conf. The Httpd.conf is a bytestream file which can be edited on the HP e3000 using "vi" or can be modified from a PC if Samba is installed on the HP e3000. shell/iX> cd /APACHE/PUB/conf shell/iX> vi httpd.conf
Setup the JHTTPD Job Stream FileThe JHTTPD.sample file should be copied to JHTTPD in PUB.APACHE and modified as needed. The /APACHE/VUUFF directory contains the new JHTTPD.sample file. The Apache installation job sets up a link to /APACHE/VUUFF so that the copy command gets the new version. shell/iX> cd /APACHE/PUB shell/iX> cp JHTTPD.sample JHTTPD shell/iX> cat JHTTPD !job jhttpd,www.apache,pub;outclass=,2 !setvar TZ 'PST8PDT' !xeq sh.hpbin.sys "-c 'umask 007;./HTTPD -f conf/httpd.conf'" !eojThe JHTTPD Job Stream File is used to run the HTTPD web server program in standalone mode within your local timezone. The timezone variable, TZ, should be set to the local timezone (for example, EST5EDT for Eastern Daylight Time, PST8PDT for Pacific Daylight Time, and MST7MDT for Mountain Daylight Time) or, TZ can be removed from JHTTPD and set in a system logon UDC. For more information about setting the timezone value, please read the POSIX help file. shell/iX> man timezonePrior to Apache 1.3.14, JHTTPD was an MPE/iX fixed-ASCII file. Starting with Apache 1.3.14, JHTTPD is a bytestream file. Note also that the file mask is set to 007 in JHTTPD. This means that files created by Apache will lack permissions for "other". This feature tightens security so that Apache-created files are accessible only within the APACHE account. The JHTTPD file does not come with a password. If desired, the JOBSECURITY command can be used to provide password protection without adding your password to the JHTTPD file. Start ApacheStart the HTTPD web server program by streaming the JHTTPD job file. This can be done from either the CI or the POSIX shell: :STREAM JHTTPD.PUB.APACHEor :XEQ SH.HPBIN.SYS -L shell/iX>callci "stream jhttpd.pub.apache" Verify that Apache is RunningThere are a number of ways to verify if the Apache web server is running or, if it is not, to isolate how far the startup process has progressed. After streaming the JHTTPD file, use :SHOWJOB to view the running job: JOBNUM STATE IPRI JIN JLIST INTRODUCED JOB NAME #J16 EXEC 10S LP TUE 10:27A JHTTPD,WWW.APACHEAnother method used to check server status, is executing :SHOWPROC at the CI or using ps from the POSIX shell. Here the parent HTTPD process is PIN 76, the child of SH.HPBIN.SYS. :SHOWPROC; job=httpd,www.apache QPRI CPUTIME STATE JOBNUM PIN (PROGRAM) STEP D202 0:00.182 WAIT J321 75 :XEQ sh.hpbin.sys "-c 'umask 007;./HTTPD -$ D202 0:00.202 WAIT J321 65 (SH.HPBIN.SYS) -c 'umask 007;./HTTPD -f $ D202 0:03.313 WAIT J321 76 (HTTPD.PUB.APACHE) D202 0:00.053 WAIT J321 91 (HTTPD.PUB.APACHE) D202 0:00.050 WAIT J321 79 (HTTPD.PUB.APACHE) D202 0:00.051 WAIT J321 43 (HTTPD.PUB.APACHE) D202 0:00.049 WAIT J321 95 (HTTPD.PUB.APACHE) D202 0:00.048 WAIT J321 58 (HTTPD.PUB.APACHE)Using ps to display process status shows PID 19660876 as the parent HTTPD process. It is the child of PID 36896833, SH.HPBIN.SYS. shell/iX> ps -ef | grep HTTPD WWW.APACHE 15466539 19660876 0 Dec 31 ldev10 0:00 HTTPD.PUB.APACHE WWW.APACHE 11010106 19660876 0 Dec 31 ldev10 0:00 HTTPD.PUB.APACHE WWW.APACHE 36896833 15204427 0 Dec 31 ldev10 0:00 SH.HPBIN.SYS info=-c 'umask 007;./HTTPD WWW.APACHE 19660876 36896833 0 Dec 31 ldev10 0:03 HTTPD.PUB.APACHE WWW.APACHE 23527503 19660876 0 Dec 31 ldev10 0:00 HTTPD.PUB.APACHE WWW.APACHE 23396443 19660876 0 Dec 31 ldev10 0:00 HTTPD.PUB.APACHE WWW.APACHE 24510559 19660876 0 Dec 31 ldev10 0:00 HTTPD.PUB.APACHEAfter the HTTPD program is running, verify that files in the directory tree are accessible:
shell/iX> cd /APACHE/PUB/public_html shell/iX> cp /APACHE/VUUFF/public_html/index.html.sample index.html
Troubleshooting Apache Setup ProblemsIf unsuccessful in starting the HTTPD program, get more information about the problem by trying one or more of these troubleshooting techniques:
$telnet hostname 80 (from a UNIX machine) Trying... Connected to hostname.hp.com. Escape character is '^]'. GET / HTTP/1.0<RETURN><RETURN> <--- user inputor :xeq telnet.arpa.sys (from an MPE machine) Telnet Client [A6000000] (C) Hewlett-Packard Co. 1994 telnet> toggle crlf Will send carriage returns as telnet <CR><LF>. telnet> open hostname 80 Trying... Connected to hostname.hp.com. Escape character is '^]'. Failed to turn on single echo: 68. GET / HTTP/1.0<RETURN><RETURN> <--- user inputThe telnet connection should successfully read the /APACHE/PUB/htdocs/index.html file. Stopping ApacheApache can be stopped by issuing an :ABORTJOB or kill. Kill can be issued by users WWW.APACHE, MGR.APACHE, and MANAGER.SYS. Using kill (which defaults to kill -TERM) is the preferred method for stopping Apache since it uses Apache's internal routines to clean up open resources. Using :ABORTJOB will result in leaked SVIPC semaphores. The CI command file IPCS.HPBIN.SYS can be used to display SVIPC semaphores and the CI command file IPCRM.HPBIN.SYS can be used to free leaked semaphores. To stop Apache from the POSIX's shell: shell/iX>kill `cat /APACHE/PUB/logs/httpd.pid`To stop Apache from the CI: :HELLO MGR.APACHE :XEQ SH.HPBIN.SYS "-c 'kill `cat /APACHE/PUB/logs/httpd.pid`'"If kill cannot be used, Apache can be stopped with :ABORTJOB as a last resort from either the CI or POSIX shell: :ABORTJOB JHTTPD,WWW.APACHEor :XEQ SH.HPBIN.SYS -L shell/iX>callci "abortjob jhttp,www.apache" Restarting ApacheApache can be restarted by issuing a kill -HUP. A restart will cause Apache to reread its configuration files without having to stop and restream the Apache job stream file. Restart is useful for making configuration changes without disrupting web users. After a restart, Apache continues running with the new configuration settings. To restart Apache: shell/iX>kill -HUP `cat /APACHE/PUB/logs/httpd.pid`or :XEQ SH.HPBIN.SYS "-c 'kill -HUP `cat /APACHE/PUB/logs/httpd.pid`'"Stopping or restarting Apache using kill may cause the error_log to contain numerous warning messages about the child processes not exiting promptly. Error LoggingApache error logging is useful when trying to start Apache as well as for monitoring a running web server. Apache will log errors into a log file called error_log by default. This log file resides in the /APACHE/PUB/logs directory. The number of messages logged in the error log is set by the LogLevel directive in the httpd.conf file. Possible values for LogLevel (by increasing significance) are debug, info, notice, warn, error, crit, alert, emerg. When a particular level is specified, messages from all other levels of higher significance are reported as well. For example, when LogLevel is "info", then messages with log levels of notice, warn and up to emerg are also posted. By default, the level is set to warn. Using a level of at least crit is recommended. Managing Log FilesApache log files can grow quite large, especially for high traffic sites. It's best to monitor the size of the log files and periodically purge or archive them. Purge or rename log files only while Apache is stopped or after restarting Apache. This is necessary because Apache continues to write to these files while it is running: :HELLO MGR.APACHE,PUB :XEQ SH.HPBIN.SYS -L shell/iX> cd logs shell/iX> mv access_log access_log.old (Apache is writing to access_log.old) shell/iX> mv error_log error_log.old (Apache is writing to error_log.old) shell/iX> kill -HUP 'cat httpd.pid'After executing the kill -HUP, Apache is no longer writing to the *.old files. Apache is now writing to a new error_log and a new access_log and the *.old files can be purged or archived. Adding DocumentsThere are several ways to add content to the Apache web server:
shell/iX> cd /APACHE/PUB/htdocs shell/iX> mkdir newdir shell/iX> chown MGR.APACHE:APACHE newdir shell/iX> chmod 750 newdirTo check if a file is accessible to the Apache web server, logon as the Apache runtime user, WWW.APACHE and try to access the file. Working with Dynamic Shared Objects (DSOs)DSOs are add-on modules that extend the functionality of Apache. These modules are self-contained code that can provide a wide-range of additional Apache capabilities such as custom authentication and authorization, custom logging, or creating new configuration directives. Users can create their own Apache modules or use those written by others. For instance, the Apache Module Registry (http://modules.apache.org/) is a web site with downloadable Apache modules. Some of these modules are freely available while others have various license restrictions. DSOs on MPE/iX can utilize Apache's full Application Programming Interface (API) as well as Apache's full Extended Application Programming Interface (EAPI). A DSO is an Apache module with the same structure as the modules compiled into the Apache binary. But instead of being statically linked into the Apache program, the DSO module is created as a shared library (NMXL). DSOs are loaded at Apache startup into Apache's process space. No recompilation of Apache is necessary to use DSOs. However, DSOs require a DSO-enabled Apache. Apache for MPE/iX is enabled for DSOs starting with Apache 1.3.9 (A.01.00). Using DSO modules keeps Apache memory usage low by running an Apache binary with core features only and adding additional features with DSOs. DSOs also provide flexibility. An installation can pick and choose which features to include in their web server. Creating Apache ModulesDSOs 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: 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 "Sample Module (mod_hw)". 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. ToolsThere are a number of options available when choosing tools to build an Apache module for MPE/iX. Some of these tools are open source tools from the GNU Project, a provider of free software. The GNU tools are used on many operating system platforms for development of open source code, including MPE/iX. Module compilations on MPE/iX can be done with the GNU C compiler, gcc, or with the MPE/iX POSIX compiler, c89. HP recommends using gcc for compiling open source modules since most open source code is designed for compilation by gcc. For example, Apache for MPE/iX is compiled with gcc. Use c89 when calling MPE/iX intrinsics or using long pointers. When using a Makefile to build a module, it can be executed with GNU make or with the MPE/iX POSIX make. GNU make is recommended for executing a Makefile created by apxs since this file is generated by open source code. The GNU tools' installation script installs GNU make in /usr/local/bin/make. MPE/iX make resides in /bin/make. Modules can be lined with GNU ld or with the MPE/iX LinkEditor. HP recommends using LinkEditor for linking Apache modules since the LinkEditor creates shared libraries that work well with dynamic loading. Make, gcc, and ld are part of the GNU tools which are downloadable from http://jazz.external.hp.com/src/gnu/gnuframe.html. Support contracts for gcc are available from http://www.gccsupport.html. LinkEditor, c89 and /bin/make are supported by HP. The Apache C header files are required when compiling an Apache module. These header files are distributed with the Apache product and reside in /APACHE/PUB/include. Module Creation Using a TemplateAny existing Apache module can be used as a template for a new module. Mod_example.c is distributed with Apache in /APACHE/PUB/libexec and makes a useful template for a simple module. When compiled and linked as the shared library (NMXL) mod_example.so, this module is a fully working DSO. Libexec/mod_example.so has already been pre-built. For a more functional module, try a different module as your template. For instance, to create a new module that does authentication, starting with one of Apache's authentication modules may be more appropriate. If you want to create a module that has its own configuration directives, start with another module that already does this. To create the module file "mod_hw.c" from file "mod_example.c", log on as MGR.APACHE so that the file is created with the right ownership: :HELLO MGR.APACHE :XEQ SH.HPBIN.SYS -L shell/iX> mkdir hw shell/iX> cd hw shell/iX> cp /APACHE/PUB/libexec/mod_example.c mod_hw.cChange all references inside mod_hw.c from mod_example, example_module, example_handler, etc. to mod_hw, hw_module, hw_handler, etc., and modify/add any other code, as needed. Creating a separate directory for the module, such as hw, separates it from other modules under development. To compile a module, certain compile options must be specified and the Apache C header files must also be included. Below, gcc creates two object files, hw.o and mod_hw.o, using the necessary options and include files. Use the -c option for compilation: shell/iX> gcc -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE -DNO_DBM_REWRITEMAP -DUSE_HSREGEX -DEAPI -DSHARED_MODULE -I/APACHE/PUB/include -c mod_hw.c hw.cNext, link the module. The link steps will be different when calling external functions that reside in archive or shared libraries. Other examples of linking are shown later. To link, the MPE/iX LinkEditor can be called from the CI or the POSIX shell: :linkedit or shell/iX> callci linkeditLinkEd> buildxl xl=./mod_hw.so;limit=5 LinkEd> addxl from=./mod_hw.o,./hw.o;to=./mod_hw.so; rl=/lib/libm.a,/lib/libc.a;merge;share 1 OBJECT FILE HAS BEEN ADDED.The "rl=" option is used to specify which archive libraries are used to resolve external function calls. The math library (/lib/libm.a) is specified here to resolve pow() in mod_hw.o. /lib/libc.a is not actually needed by the sample code. But it is a good practice to always specify libc since most modules and other libraries are likely to need functions from this library. If libc is not specified explicitly as shown here, the MPE/iX C library will be used by default (LIBC.LIB.SYS). Since Apache is built with libc, we recommend explicitly specifying /lib/libc instead of defaulting to LIBC.LIB.SYS. /lib/libc and LIBC.LIB.SYS are not identical. The order of the libraries listed by "rl=" is important and libc should always be specified last. The merge directive is necessary when functions are called across object boundaries such as mod_hw.o calling helloworld() in hw.o. The share option is needed when global data is shared between multiple object files. The share option is not actually needed by the sample code. The compile and link steps can be put in a Makefile to facilitate multiple builds of a module. As an example, refer to the section "Modified APXS Makefile (mod_hw)". Mod_hw.so is now ready to be configured into Apache. To do this, refer to the section "Configuring Apache Modules". Module Creation Using the APXS UtilityModules can also be created using the bin/apxs utility "Apache eXtenSion" tool. Details on using apxs are found in the apx manual page, http://www.apache.org/docs/programs/apxs.html. Apxs is a Perl script and requires a working Perl interpreter on the HP e3000. The Perl interpreter is not distributed as part of FOS but is available as freeware via http://jazz.external.hp.com. To prepare a system for running apxs:
shell/iX> ln -s /PERL/PUB/PERL /usr/local/bin/perlApxs has a number of options. The -g and -n options will create a module skeleton with a corresponding Makefile. Log on as MGR.APACHE in order to execute apxs and to create a module with MGR.APACHE as the owner. :HELLO MGR.APACHE :XEQ SH.HPBIN.SYS -L shell/iX> ./bin/apxs -g -n hw Creating [DIR] hw Creating [FILE] hw/Makefile Creating [FILE] hw/mod_hw.c shell/iX> cd hw shell/iX> ls Makefile mod_hw.cApxs -g -n will create directory "hw" with the module source file mod_hw.c and its Makefile. This directory is where the module is developed. Note that the mod_hw.c file created here is not the same as the sample module code. To continue following this example, use the code listings given for mod_hw.c and hw.c. Makefile can be used for compiling and linking the module. The default Makefile created here by apxs uses apxs for compiling and linking. We recommend changing this to use gcc and LinkEditor as shown in the section "Modified APXS Makefile (mod_hw)". The modified Makefile still calls apxs for getting the correct compile options and include files but does not use apxs for compiling and linking. Makefile can easily be modified for customization. For the sample module, mod_hw, the additional source file, hw.c, was added to Makefile. Using a Makefile is a convenient and flexible way to build modules. Here is the output from executing mod_hw's modified apxs Makefile: shell/iX> cd /APACHER/PUB/hw shell/iX> makegcc -o mod_hw.o `/APACHE/PUB/bin/apxs -q CFLAGS` \ -I`/APACHE/PUB/bin/apxs -q INCLUDEDIR` -c mod_hw.c gcc -o hw.o `/APACHE/PUB/bin/apxs -q CFLAGS` -I`/APACHE/PUB/bin/apxs -q INCLUDEDIR` \ -c hw.c callci "linkedit 'buildxl xl=./mod_hw.so;limit=5'" HP Link Editor/iX (HP30315A.06.15) Copyright Hewlett-Packard Co 1986 LinkEd> buildxl xl=./mod_hw.so;limit=5 LinkEd> addxl from=./mod_hw.o,./hw.o;to=./mod_hw.so; rl=/lib/libm.a,/lib/libc.a ;merge;share 1 OBJECT FILE HAS BEEN ADDED. Linking Libraries into a DSOWhen a DSO requires external library functions, as does mod_hw, these can be resolved using either archive libraries or shared libraries. With archive libraries, external calls are resolved at link time and the functions are incorporated into your DSO. With shared libraries, external calls are resolved at run time. At run time, the loader searches the shared libraries for these external functions. This section discusses the linking of a module. Linking is independent of the method used to create and compile the module code. Archive librariesArchive libraries may be either custom archive libraries (built by others) or system archive libraries. System archive libraries are ".a" files residing in /lib and /usr/lib. The following shows how to build hw.c as an archive library then link it into mod_hw.so: shell/iX> cd /APACHE/PUB/hw shell/iX> gcc -c -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE -DNO_DBM_REWRITEMAP -DUSE_HSREGEX -DEAPI -DSHARED_MODULE -I/APACHE/PUB/include hw.c shell/iX> ar -rv hw.a hw.o ar: creating hw.a a - /APACHE/PUB/hw/hw.o 1 OBJECT FILE HAS BEEN ADDED. shell/iX> callci linkedit HP Link Editor/iX (HP30315A.06.15) Copyright Hewlett-Packard Co 1986 LinkEd> buildxl xl=./mod_hw.so;limit=5 LinkEd> addxl from=./mod_hw.o;to=./mod_hw.so;merge;share;rl=./hw.a,/lib/libm.a, /lib/libc.a 1 OBJECT FILE HAS BEEN ADDED. Shared librariesShared libraries (XLs) can also be used for resolving external function calls from a DSO. One method is to relink the Apache program with an XL list of the required shared libraries and to copy each shared library into MPE/iX namespace. Another method is to link a DSO using dependent libraries the (altxl option to the LinkEditor) and to copy each shared library into MPE/iX namespace. Either way, all shared libraries must reside in an MPE/iX group and account and must follow the MPE/iX naming conventions. This is necessary because Apache is a Privileged Mode (PM) program. Symbolic links from the MPE/iX namespace to a shared library in the HFS namespace will not satisfy the PM capability constraint. Each shared library must actually reside in MPE/iX namespace. The following commands show how to copy the libm and libc system shared libraries into MPE/iX namespace and how to use the altprog option to LinkEditor to add these shared libraries to the Apache program file: :HELLO MGR.APACHE :XEQ SH.HPBIN.SYS -L shell/iX> cp /lib/libm.sl XLM shell/iX> cp /lib/libc.sl XLC shell/iX> callci linkedit LinkEd> buildxl xl=./hw/mod_hw.so;limit=10 LinkEd> addxl from=./hw/mod_hw.o,./hw/hw.o;to=./hw/mod_hw.so;merge;share LinkEd> altprog ./HTTPD;cap=ia,ba,ph,pm;xl=XLM,XLCWhen using system libraries as XLs, such as libm.sl and libc.sl, remember to recopy these libraries after a system update in order to get their new versions. To verify that HTTPD has been successfully relinked with your NMXL(s): LinkEd> listprog ./HTTPD PROGRAM : ./HTTPD XL LIST : XLM XLC CAPABILITIES : BA, IA, PM, PHHere is a POSIX script that shows how libraries might be set up programmatically. It uses hw.o as the archive library, hw.a: shell/iX> cat xlbuild.sh #!/bin/sh # # set the location of Apache AP=/APACHE/PUB # # create the old libraries rm -f ${AP}/XLC ${AP}/XLM ${AP}/XLHW # # copy the latest versions cp /lib/libc.sl ${AP}/XLC cp /lib/libm.sl ${AP}/XLM # #create a custom XL callci "xeq linkedit.pub.sys 'buildxl xl=${AP}/XLHW'" callci "xeq linkedit.pub.sys 'addxl from=${AP}/hw/hw.a;to=${AP}/XLHW;share;merge'" # # remove fragmentation and minimize the internal tables callci "xeq linkedit.pub.sys 'cleanxl ${AP}/XLHW;compact'" # # Relink Apache with the new NMXL list callci "xeq linkedit.pub.sys \ 'altprog ${AP}/HTTPD;cap=ia,ba,ph,pm;xl=\"${AP}/XLHW,${AP}/XLM,${AP}/XLC\"'" Configuring Apache ModulesOnce a DSO has been compiled and linked, it needs to be configured. DSOs can be configured manually or they can be configured with apxs. Configuration consists of copying the DSO module to a known location then updating httpd.conf to find and execute the DSO. Manual ConfigurationBy convention, DSOs written in C reside in /APACHE/PUB/libexec. After copying a DSO to this location, the AddModule and LoadModule directives must be added to httpd.conf. An example of where to place AddModule and LoadModule is shown in the httpd.conf file for mod_example. Additional directives may be necessary to configure a DSO's handler, depending on what the DSO is trying to accomplish.:HELLO MGR.APACHE :XEQ SH.HPBIN.SYS -L shell/iX> cp hw/mod_hw.so libexec/mod_hw.so shell/iX> vi conf/httpd.conf ... # Note: The order is whch modules are loaded is important. # Don't change the order below without expert advice # # Example: # LoadModule foo_module libexec/mod_foo.so # LoadModule example_module libexec/mod_example.so LoadModule hw_module libexec/mod_hw.so ... AddModule mod_cern_meta.c AddModule mod_expires.c AddModule mod_headers.c AddModule mod_usertrack.c #AddModule mod_example.c AddModule mod_jw.c AddModule mod_unique_id.c AddModule mod_so.c AddModule mod_setenvif.c ...Mod_hw includes a handler so the following additional directives are added to httpd.conf: ... <IfModule mod_hw.c> <Location /hw> SetHandler hw-handler </Location> </IfModule> ...The LoadModule directive takes two arguments. The first is the name of the module to load. This is the module's structure name taken from the source file mod_hw.c. The second argument is the path to the shared object file to load. The path can be relative to the server root (/APACHE/PUB), as shown here, or it can be an absolute path. APXS ConfigurationTo use apxs for configuration, use the install option of Makefile. This will copy a module into libexec and automatically update httpd.conf with the AddModule and LoadModule directives. Additional configuration changes may be necessary (such as manually configuring the hw-handler as shown in the manual configuration) depending on what the module does::HELLO MGR.APACHE :XEQ SH.HPBIN.SYS -L shell/iX> cd hw shell/iX> make install /APACHE/PUB/bin/apxs -i -a -n 'hw' mod_hw.so cp mod_hw.so /APACHE/PUB/libexec/mod_hw.so chmod 755 /APACHE/PUB/libexec/mod_hw.so [activating module `hw' in /APACHE/PUB/conf/httpd.conf] Testing a DSOAfter configuration or at any time after modifying a DSO, restart Apache in order to load the module: shell/iX> cd /APACHE/PUB/logs shell/iX> kill -HUP `cat ./httpd.pid`or kill -TERM 'cat httpd.pid`;callci stream ../JHTTPDTo execute the mod_hw DSO, access the <Location> specified in the httpd.conf file. A DSO may be executed in a different way, depending on the DSO's functionality: http://yourserver.com/hw The output of the mod_hw module prints "Hello World!" followed by the result of raising the number 12 to the power of 2. The following is the output seen in a browser: Hello World! The result of 12.00**2.00 is 144.00
|