Omnis Technical Note TNWE0005 Updated October 2012

Using the Apache Module with Omnis

(previous title: Using Web Client with Linux and Apache web server)

For Omnis Studio 4.x or later
By Omnis Tech Support

When you setup an Omnis web application you can realise the communication between the web server (in this case Apache) and the Omnis App Server in two different ways:

The easiest solution is the communication by a program "nph-omniscgi" which will be copied into the /cgi-bin/ directory of the web server. But it has got the disadvantage that this program has to be loaded and started whenever a web client calls the page with the Omnis application. (If you are using IIS there is an IIS-API plug-in which is faster since it is built for IIS.)

Alternatively, the Apache Server can load this functionality as an external module at the start so that it is available whenever it is needed. This is of course a better solution when many clients are connecting at the same time via the Apache Web Server with an Omnis App Server.

The general way of setting up the Omnis App Server is described in the Omnis Programming maunual in the 'Developing Web Applications' chapter. This tech note describes the configuration of the Apache module "mod_omnis.so" (supplied with Omnis) for Apache version 2.0 under SuSE Linux 9.2, and Omnis Studio version 4.x or above under Linux.

Configuration of Apache

In older Linux distributions, Apache was configured in a single very large file "/etc/http/httpd.conf". With the growing functionality of Apache this became more and more complex, therefore the configuration, for example, with SuSE 9.2, is now in several different files in which you only need to set certain environment variables. Now the main configuration file "/etc/apache2/httpd.conf" does not need to be customised at all. Other configuration files should not be modified manually, they are generated by Apache automatically.

The following steps must be executed as a "root" user:

Copy the file "mod_omnis.so" from the subdirectory "clientserver/server/apache2/" in the main Omnis base directory "/usr/local/rainingdata/os4XXweb/" into the directory "/usr/lib/apache2/", that is, to "/usr/lib/apache2/mod_omnis.so".

Edit the file "/etc/sysconfig/apache2", adding to line 152 the Omnis module:

APACHE_MODULES="access ... php4"

becomes

APACHE_MODULES="access ... php4 omnis"

In the directory "/etc/apache2/config.d/" create a file "mod_omnis.conf" with the following
content:

#
# Configuration file for Omnis Module
#
<IfModule mod_omnis.cpp>
  <Location /omnis_apache>
    SetHandler omnis-apache
  </Location>
</IfModule>

Then restart the Apache Web Server with the command

rcapache2 restart

If you receive any error messages, check the content of the file:

/var/log/apache2/rcapache2.out

You can then see that the Apache Start Script has automatically customised the file

/etc/apache2/sysconfig.d/loadmodule.conf

for the Omnis module.

Configuration of the Web Page for Omnis

Where in your HTML page you may have used the parameter:

<param name="WebServerScript" value="/cgibin/nph-omniscgi">

for Internet Explorer, and

<embed ...
WebServerScript="/cgi-bin/nph-omniscgi">

for Netscape/Mozilla based browsers, now insert:

<param name="WebServerScript" value="/omnis_apache"> ;; for IE
or
<embed ...
WebServerScript="/omnis_apache"> ;; for Netscape/Mozilla

Now the requests from your web or mobile clients will be handled by the Apache module.