Ingres Community Forums Login Register Ingres.com  

Ingres Community Wiki

Navigation
Learn About
Developing With
Ingres Talk
Information
Toolbox

Ingres with Apache on Debian and Ubuntu

From Ingres Community Wiki

Jump to: navigation, search

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 Debian or Ubuntu. Please note that this page was originally created for Debian GNU/Linux. Since Ubuntu is derived from Debian, the same steps should apply.

Pre-requisites

It is assumed that you have the following installed:

  • Ingres 2006 or newer ( Ingres >= 9.0.4 )
  • Debian 4.0 or Ubuntu 8.04
    • Earlier releases might also apply
  • Apache 2.2.3 - specifically 2.2.3-4+etch4
    • 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-debian:~$ ps -fe | grep apache | grep -v grep
root      2830     1  0 09:15 ?        00:00:02 /usr/sbin/apache2 -k start
www-data  2873  2830  0 09:15 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2874  2830  0 09:15 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2875  2830  0 09:15 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2876  2830  0 09:15 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2877  2830  0 09:15 ?        00:00:00 /usr/sbin/apache2 -k start

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 www-data account will be used to connect to Ingres.

To add www-data to Ingres run the following, as the ingres administrator:

sql iidbdb <<EOSQL
create user "www-data"\g
commit\g
\q
EOSQL

You should see something similar to:

ingres@esva-debian:~$ sql iidbdb <<EOSQL
> create user "www-data"\g
> commit\g
> \q
> EOSQL
INGRES TERMINAL MONITOR Copyright 2007 Ingres Corporation
Ingres 2006 Release 2 Linux Version II 9.1.1 (int.lnx/103)NPTL login
Thu Aug  7 09:30:35 2008

continue
* Executing . . .

continue
* Executing . . . 

continue
* Ingres 2006 Release 2 Version II 9.1.1 (int.lnx/103)NPTL logout
Thu Aug  7 09:30:36 2008

Now the Ingres DBMS is setup for the Apache web server on Debian.

Enabling Apache for Ingres

  1. Edit /etc/apache2/envvars to 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 - ODBCSYSINI is only needed for the Python driver
  2. Edit /etc/apache2/mods-available/ingres.conf to include the following:
  3. PassEnv II_SYSTEM LD_LIBRARY_PATH ODBCSYSINI
  4. Activate ingres.conf:
  5. ln -s  /etc/apache2/mods-available/ingres.conf /etc/apache2/mods-enabled/ingres.conf
  6. Restart apache:
    /etc/init.d/apache2 restart

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 :" .$_ENV["II_SYSTEM"] . "<br/>\n";
  echo "LD_LIBRARY_PATH is :" .$_ENV["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>')
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.

Personal tools
© 2009 Ingres Corporation. All Rights Reserved