This site is now 100% read-only, and retired.

Connect to Informix using PHP5 on Lenny x86_64

Posted by esullaway on Tue 24 Nov 2009 at 09:29

After much trial and error, I have a Debian Lenny x86_64 server with apache2, php5, and connectivity to an Informix database server. Here are the steps I went through. Much of this information I found at http://devzone.zend.com/article/4290.

Taking a 'basic installation' of Debian Lenny.

The environment variable and path variable was changed in /etc/profile I have used /opt/IBM as where I will install the Informix client, you can pick a different location if you desire.

Before the 'export PATH' line, add the following

export INFORMIXDIR=/opt/IBM

PATH=$PATH:$INFORMIXDIR/bin

The INFORMIXDIR will have to be set before the client can be installed in addition to compiling the php_informix module later.

debian:~# export INFORMIXDIR=/opt/IBM

The Informix client requires the Informix system user and group before it can be installed

debian:~# addgroup --system informix

debian:~# adduser --system informix --ingroup informix

Packages to install sun-java-jdk rpm php5-dev php-config make libapache2-mod-php5 You may need to make some changes to your sources list in apt to get the non-free sun java packages. The Informix client installer comes with a jvm but seems to error out if you use that one, installing the sun-java package worked for me.

debian:~# apt-get install sun-java-jdk rpm php5-dev php-config make libapache2-mod-php5 subversion

You will have to accept the sun-java licence during the install

Creating directories for installing the Informix client and php_informix.

debian:# mkdir informix_client

debian:# mkdir php_informix

Download the Informix client into the informix client directory. As far as I know, there is no easy way to do this from the command line. I had to register with IBM's website and download a free trial. If you go to IBM's website and put the following into the search box you should come up with the package I used successfully. IBM Informix Client SDK V3.00.FC3 for Linux (x86) RHEL 4, 64bit The file I downloaded was clientsdk.3.00.FC3DE.LINUX.tar

Expand the informix client

debian:~/informix_client# tar -xvf clientsdk.3.00.FC3DE.LINUX.tar

Run the installclientsdk.

debian:~/informix_client# ./installclientsdk

You may have to change the location of the Install Location directory. I used /opt/IBM/ for my location. You will have to agree to the license and walk through the install.

Change to the php_informix directory.

debian:~/informix_client# cd ../php_informix

Download the php_informix source from svn.

debian:~/php_informix# svn checkout http://svn.php.net/repository/pecl/informix/trunk/

Change to the trunk directory

debian:~/php_informix# cd trunk

Now to build and install the Informix module.

debian:~/php_informix/trunk# phpize --with-php-config=/usr/bin/php-config

debian:~/php_informix/trunk# ./configure --with-php-config=/usr/bin/php-config

Before continuing with the make of the Informix Module, you must edit the Makefile to ensure that the module is linked with Informix library checkapi.o, otherwise the use of the module will produce the error: undefined symbol: ifx_checkAPI.

Inside Makefile should replace the value of the directive INFORMIX_SHARED_LIBADD with:

-Wl,-rpath,/opt/IBM/informix/lib/esql -L/opt/IBM/informix/lib/esql -Wl,-rpath,/opt/IBM/informix/lib -L/opt/IBM/informix/lib -lifsql -lifasf -lifgen -lifos -lifgls -ldl -lcrypt /opt/IBM/lib/esql/checkapi.o -lifglx

Now proceed with the build and installation of the Informix module:

debian:~/php_informix/trunk# make && make install

The module should be installed in /usr/lib/php5/20060613. You should verify the correct link to the library Informix checkapi.o just using the nm command, and should get a result like this:

debian:~/php_informix/trunk# nm /usr/lib/php5/20060613/informix.so | grep ifx_checkAPI

000000000000bef0 T ifx_checkAPI

Now to add/enable the module. Edit/create a informix.ini file under /etc/php5/conf.d/ directory

debian:/# vi /etc/php5/conf.d/informix.ini

# configuration for php INFORMIX module
extension=informix.so

There are some other files which will need to be edited for the Informix client to work. The /opt/IBM/etc/sqlhosts, the /etc/hosts, and /etc/services must have lines entered/changed for the configuration of your Informix environment. Also may need to set the INFORMIXDIR apache environment variable in /etc/apache2/apache2.conf.

 

 


Re: Connect to Informix using PHP5 on Lenny x86_64
Posted by Anonymous (91.193.xx.xx) on Thu 29 Dec 2011 at 13:48
try
1. install Informix CSDK
2. setup server connection in $INFORMIXDIR/etc/sqlhosts
3. setup unixODBC last version
4. in php-script add lines
==========index.php===============================
putenv('INFORMIXDIR=/opt/informix');
putenv('ODBCINI=/etc/odbc.ini');
putenv('PATH=%PATH%:$INFORMIXDIR/lib/esql:$INFORMIXDIR/lib/cl i');
/* some else variables if need
DBDATE, DBTIME, DBMONEY, DB_LOCALE, CLIENT_LOCALE, LANG
*/

// and try use
$link = odbc_connect('odbc_alias_name','user/,'pass') ;
$res = odbc_exec($link,'select filedname from table');
$out = odbc_result($res,1);
echo $out;
==================================================

[ Parent ]

Re: Connect to Informix using PHP5 on Lenny x86_64
Posted by Anonymous (79.35.xx.xx) on Fri 22 Feb 2013 at 21:38
Thanks for suggesting the source of some of the information.

Antonio Musarra.
musarra.wordpress.com

[ Parent ]