Apache is different to the Microsoft and Netscape Web servers in that it does not support the Microsoft/Netscape style of API. However, extra functionality can be added to Apache by means of user-defined modules (compiled C programs). In fact, a large part of Apache's core functionality is implemented as a set of modules.
Unfortunately, adding a new module to Apache involves reconfiguring and rebuilding the Web server. A WebLink module is provided for this purpose. For those who do not wish to rebuild their Web server, WebLink also provides a high-performance CGI-based solution. Both the WebLink module and the CGI executables are small functional blocks designed to exclusively communicate with WebLink's Network Service Daemon (NSD). The NSD is responsible for providing WebLink's core functionality and persistent links to Caché.
The key decision to make at this point is whether or not you wish to rebuild the Apache Web server in order to add the WebLink module or opt for the less complicated CGI solution instead. The performance of the two approaches appears to be similar though, technically, the bound-in module ought to be faster. Read on to the section describing how you add WebLink's module for guidance on how to build the module into the Apache core or skip to the section describing how you add WebLink's CGI module for the CGI-based approach.
The code for user-defined modules resides under directory:
/apache/src/modules
/apache/src/modules/weblink
mkdir weblink
/apache/src/modules/weblink/mod_weblink.c
Now we need to create a Makefile. The Makefile contains instructions on how the WebLink module should be compiled and linked. Apache always provides an example module - we will make a copy of the example's Makefile and modify it for WebLink.
Make sure you are in the weblink directory:
/apache/src/modules/weblink
cp ../example/Makefile* ./
For Apache 1.3.x: Makefile
For Apache 1.3.x: Makefile.tmpl (Makefile template)
Edit whichever file you have and replace all references to mod_example with mod_weblink.
/apache/src
For Apache 1.2.x:
Near the end of this file you should find the line:
# Module example_module modules/example/mod_example.o
Module weblink_module modules/weblink/mod_weblink.o
Near the end of this file you should find the line:
# AddModule modules/example/mod_example.o
AddModule modules/weblink/mod_weblink.o
You can now configure the build process. Make sure you are in the src directory:
/apache/src
./Configure
For Apache 1.2.x:
/apache/src/httpd.h
/apache/src/include/httpd.h
#define HTTPD_ROOT "/etc/httpd"
We can now build the Apache executable. Make sure you are in the src directory:
/apache/src
make
For Red Hat Linux, the executable httpd should be copied to:
/usr/sbin
Edit the Apache configuration file httpd.conf. For the standard Apache distribution this file will be found in:
/apache/conf
/etc/httpd/conf
<Location /scripts>
SetHandler weblink-handler
</Location>
The /scripts directory should be created below the documents root. For the standard Apache distribution this will be:
/apache/htdocs
/apache/htdocs/scripts
/home/httpd/html
/home/httpd/html/scripts
Copy the two WebLink-CGI executables (mgwcgi and nph-mgwcgi) into the CGI directory, which for the standard Apache distribution is:
/apache/cgi-bin
/home/httpd/cgi-bin
Note that WebLink's CGI modules are also available for NT/95/98 platforms (mgwcgi.exe and nph-mgwcgi.exe). Note also that because CGI is an open standard, WebLink's CGI modules will work with any Web server.
In order for the two Web connectivity options to operate, the WebLink NSD must be up and running. If necessary, create the following directory directly below the system root:
/cachesys/weblink
To start the NSD type:
./mgwmt
./mgwmt <port_no>
All startup messages for this command can be suppressed using the -s qualifier. For example, if you wish to silently start the NSD from a script invoked when the system is booted use:
/cachesys/weblink/mgwmt -s [port_no]
kill -TERM `cat /cachesys/weblink/wlserver.pid`
All errors will be reported in WebLink's event log (i.e. mgw.log). This file will be created and maintained in the /cachesys/weblink directory. WebLink's configuration file mgw.ini will also reside in this directory.
The NSD will also create the following file:
/cachesys/weblink/wlserver.ini
Having started the WebLink NSD, you are ready to start Apache and run WebLink applications. The order in which these services are started does not actually matter.
If you chose the WebLink module approach, point your browser at:
http://<ip_address>/scripts/mgwms32.dll
http://<ip_address>/cgi-bin/nph-mgwcgi
WebLink and WebLink-based applications usually assume the responsibility for sending a full HTTP header. Under CGI, the first line of the header (the request status line) has traditionally been the responsibility of the server-side of the CGI interface. Some Web servers are strict about this - Apache is one such example. Apache expects the first header line sent by your application to be the Content-type line and not the request status line (e.g. HTTP/1.0 200 OK) - it will return an error if it parses the header and does not detect a Content-type line first. Using the 'nph' version of the CGI module alleviates this problem. Not all Web servers are so strict about this - Microsoft's Web server does not object to receiving a full HTTP header via mgwcgi.exe.