Ingres Community Forums Login Register Ingres.com  

Ingres Community Wiki

Navigation
Learn About
Developing With
Ingres Talk
Information
Toolbox

Ingres with Apache on Mac OS X (Leopard)

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 Mac OS X Leopard.

Pre-requisites

It is assumed that you have the following installed:

  • Ingres 2006 or newer ( Ingres >= 9.0.4 )
  • Apple Mac OS X 10.5
    • Earlier releases might also apply, but pre-Leopard desktops are normally Apache 1.x
  • Apache 2.2.x (Use /usr/sbin/apachectl -v on Mac and Linux to see the version number)
    • 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:

grep "^User" /private/etc/apache2/httpd.conf 


On my system I get the following:


grant@mac: ~ $ grep -r "^User" /private/etc/apache2/httpd.conf 
User www

The account www is the effective user that will be seen by Ingres. To add www to Ingres run the following, as the ingres administrator:

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

You should see something similar to:

ingres@mac: ~ $ sql iidbdb <<EOSQL
> create user "www"\g
> commit\g
> \q
> EOSQL
INGRES TERMINAL MONITOR Copyright 2008 Ingres Corporation
Ingres 2006 Release 4 Mac OS X (Darwin) Version II 9.3.0 (int.osx/119) login
Thu Jan  8 18:48:38 2009
continue
* Executing . . .

continue
* Executing . . .

continue
* Ingres 2006 Release 4 Version II 9.3.0 (int.osx/119) logout
Thu Jan  8 18:48:38 2009

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

Enabling Apache for Ingres

  1. Edit /System/Library/LaunchDaemons/org.apache.httpd.plist to include the following after the first <dict>:
        <key>EnvironmentVariables</key>
        <dict>
            <key>DYLD_LIBRARY_PATH</key>
            <string>/lib:/usr/lib:/usr/local/lib:/opt/Ingres/IngresII/ingres/lib:/opt/Ingres/IngresII/ingres/lib/lp32</string>
            <key>II_SYSTEM</key>
            <string>/opt/Ingres/IngresII</string>
            <key>ODBCSYSINI</key>
            <string>/opt/Ingres/IngresII/ingres/files</string>
        </dict>
    Note - ODBCSYSINI is only needed for the Python driver
  2. Edit /private/etc/apache2/other/ingres.conf to include the following:
  3. <IfModule env_module>
        PassEnv II_SYSTEM
        PassEnv DYLD_LIBRARY_PATH
        PassEnv ODBCSYSINI
     </IfModule>
  4. Restart apache: sudo apachectl 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

To active PHP support in Apache on Mac OS X follow this guide

  • 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/IngresII
LD_LIBRARY_PATH is :/lib:/usr/lib:/usr/local/lib:/opt/Ingres/IngresII/ingres/lib:/opt/Ingres/IngresII/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/IngresII
LD_LIBRARY_PATH	/lib:/usr/lib:/usr/local/lib:/opt/Ingres/IngresII/ingres/lib:/opt/Ingres/IngresII/ingres/lib/lp32

Feedback

If you have any feedback please contact Grant Croker.

Personal tools
© 2009 Ingres Corporation. All Rights Reserved