This is a guide to save you from banging your head against a wall, in case you ever want to get PHP talk with Ingres on a CentOS machine.
After hours of searching around and not finding not one damn proper guide, I decided to just write one down (after much trial and error).
What we wanna do is basically query an Ingres database through a CentOS based LAMP server (which runs WHM/CPanel too). So we need to install (unfortunately) the Ingres Community Database (as the PECL Ingres package seems to require it to be installed) and of course we need to install PHP's package for Ingres (PECL Ingres) so we can query an Ingres database from PHP. Still with me?
Let's get started...
1. Install Ingres and PHP/Ingres support on CentOS:
Install Ingres DB Community Edition first as it's obviously required by PECL's Ingres package. Here we install the related RPM for a 32-bit CentOS machine. The process is the same for 64-bit, the file is just different. Sign up on ingres.com for a free account and go to http://www.ingres.com/downloads/ingres-database.php to download the right release. Ingres.com is passing the download link from some script, so if you wanna pinpoint the URL and not download the file to your PC, then upload onto your server, you can simply right-click on the download manager in Firefox and copy the "link location". This will give you the URL where the actual file of the Ingres db relies on the ingres.com site, so you can use "wget". In this case, the path I got was something like "http://98.129.177.132/~GqxCOi/ingres-10.0.0-119-NPTL-gpl-pc-linux-i386.tgz". Don't try this link in particular as it may not work when you read this...
You obviously need root access to the server:
# cd /usr/src # wget http://98.129.177.132/~GqxCOi/ingres-10.0.0-119-NPTL-gpl-pc-linux-i386.tgz # tar -zxvf ingres-10.0.0-119-NPTL-gpl-pc-linux-i386.tgz # cd ingres-10.0.0-119-NPTL-gpl-pc-linux-i386 # sh ingres_express_install.sh
This process will install Ingres in /opt/Ingres/IngresII/
2. Install the PECL Ingres package for PHP.Using "pecl install ingres" will simply NOT work. So we do it the old-fashioned way. Grab the latest package here: http://pecl.php.net/package/ingres and then do the following:
# cd /usr/src # wget http://pecl.php.net/get/ingres-2.2.2.tgz # tar -zxvf ingres-2.2.2.tgz # cd ingres-2.2.2 # phpize # ./configure --with-ingres=/opt/Ingres/IngresII # make # make install
This process will install the PECL Ingres package for PHP.
We need a couple more things, before we get started.We need to declare some system variables in Apache. If you use WHM/CPanel, go to Main >> Service Configuration >> Apache Configuration >> Include Editor and choose to edit the "Pre Main Include" file. Add the following 2 lines:
SetEnv II_SYSTEM /opt/Ingres/IngresII SetEnv LD_LIBRARY_PATH /opt/Ingres/IngresII/ingres/lib
If you don't use Cpanel, just paste these lines into your httpd.conf file.
Now locate the WHM/CPanel php.ini file at /usr/local/lib/php.ini (if you don't use WHM/Cpanel it's probably located in /usr/lib/php.ini). Find the line "; Directory in which the loadable extensions (modules) reside." and right after that add:extension = "ingres.so"
This will make sure the related PHP extension for Ingres support is loaded by PHP.
That's it.Go to your "public_html" folder (or any other folder) and test if you got Ingres support for PHP installed properly. We'll use a dummy connection file, so get the code below:<?php $link = ingres_connect("database", "user", "password") or die("Could not connect: " . ingres_error($link)); echo "Connected successfully"; ?>
…and save this as "ingres.php". Now visit this file from your browser and if you get a "Warning: ingres_connect()..." then it means Ingress support for PHP is installed properly!
Enjoy!