Navigation
Learn About
Developing With
Ingres Talk
Information
Toolbox
Views
Ingres with Apache on SUSE Linux
From Ingres Community Wiki
Contents |
Introduction
Getting web applications to connect to Ingres via Apache on UNIX/Linux can be quite fiddly. Here is a simple guide on the setup steps needed to allow the Ingres PHP, Python and Ruby drivers to work with Apache on SuSE Linux.
Pre-requisites
It is assumed that you have the following installed:
- Ingres 2006 or newer ( Ingres >= 9.0.4 )
- openSuSE 11.0 or newer / SuSE Linux Enterprise Server / Desktop (SLES/SLED) 9
- Earlier releases might also apply
- Apache 2.2.8
- The steps here apply to other releases of Apache from 1.3 onwards
- mod_env - An Apache module which modifies the environment which is passed to CGI scripts and SSI pages
Enabling Ingres for Apache
Any user that connects to Ingres must be a known (defined) user. Specifically a user account must be created within Ingres using CREATE USER .... In the case of web applications served by Apache, Tomcat or whatever, the server process owner is the user that Ingres will initially see. To determine the process owner for Apache execute the following:
ps -fe | grep apache | grep -v grep
On my system I get the following:
grant@esva-suse:~$ ps -fe | grep apache | grep -v grep root 14056 1 4 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf wwwrun 14060 14056 0 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf wwwrun 14074 14056 0 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf wwwrun 14076 14056 0 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf wwwrun 14077 14056 0 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf wwwrun 14078 14056 0 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf wwwrun 14079 14056 0 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf wwwrun 14080 14056 0 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf wwwrun 14081 14056 0 08:26 ? 00:00:00 /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
Which shows two user accounts for Apache. The root account can be ignored since it is a monitor/control process that starts up and shuts down servers as required. The processes run under the wwwrun' account will be used to connect to Ingres.
To add wwwrun to Ingres run the following, as the ingres administrator:
sql iidbdb <<EOSQL create user wwwrun\g commit\g \q EOSQL
You should see something similar to:
ingres@esva-suse:~> sql iidbdb <<EOSQL > create user wwwrun\g > commit\g > \q > EOSQL INGRES TERMINAL MONITOR Copyright 2008 Ingres Corporation Ingres Linux Version II 9.2.0 (int.lnx/141)NPTL login Tue May 19 22:18:42 2009 continue * Executing . . . continue * Executing . . . continue * Ingres Version II 9.2.0 (int.lnx/141)NPTL logout Tue May 19 22:18:42 2009
Now the Ingres DBMS is setup for the Apache web server.
Enabling Apache for Ingres
- Edit
/usr/share/apache2/load_configurationto include the following:II_SYSTEM=/opt/Ingres/IngresII LD_LIBRARY_PATH=/opt/Ingres/IngresII/ingres/lib ODBCSYSINI=/opt/Ingres/IngresII/ingres/files export II_SYSTEM LD_LIBRARY_PATH ODBCSYSINI
Note -ODBCSYSINIis only needed for the Python driver - Create a new config file,
/etc/apache2/conf.d/ingres.conf, adding the following: - Restart apache: /etc/init.d/apache2 restart
PassEnv II_SYSTEM LD_LIBRARY_PATH ODBCSYSINI
Verifying the setup
To see that the environment variables are visible the following code snippets can be executed through Apache through PHP and mod_python.
PHP
- Code:
<?php echo "II_SYSTEM is :" .$_SERVER["II_SYSTEM"] . "<br/>\n"; echo "LD_LIBRARY_PATH is :" .$_SERVER["LD_LIBRARY_PATH"] . "<br/>\n"; ?>
- Sample Output:
II_SYSTEM is :/opt/Ingres/II LD_LIBRARY_PATH is :/lib:/usr/lib:/usr/local/lib:/opt/Ingres/II/ingres/lib:/opt/Ingres/II/ingres/lib/lp32
Python
- Code, save as
env.py:
from mod_python import apache
def environment(req):
req.content_type = "text/html"
req.add_common_vars()
env_vars = req.subprocess_env.copy()
req.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
req.write('<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">')
req.write('<head><title>mod_python.publisher</title></head>')
req.write('<body>')
req.write('<h1>Environment Variables</h1>')
req.write('<table border="1">')
req.write('<tr><td>%s</td><td>%s</td></tr>' % ("II_SYSTEM", env_vars['II_SYSTEM']))
req.write('<tr><td>%s</td><td>%s</td></tr>' % ("LD_LIBRARY_PATH", env_vars['LD_LIBRARY_PATH']))
req.write('</table>')
req.write('</body>')
req.write('</html>')
- Ouput from http://localhost/env.py/environment:
Environment Variables II_SYSTEM /opt/Ingres/II LD_LIBRARY_PATH /lib:/usr/lib:/usr/local/lib:/opt/Ingres/II/ingres/lib:/opt/Ingres/II/ingres/lib/lp32
Feedback
If you have any feedback please contact Grant Croker.

