You are here

Installing PDO_INFORMIX on CentOS6

Step#1 : Install the Informix SDK / Client

This is as simple as copying the files to /opt/informix or using one of the various install methods provided. But beyond that it is necessarily to initialize the required environment variables. The simplest way to set the environment variables is to create an informix.sh profile script in /etc/profile.d - these scripts are executed by /etc/profile whenever a session is created [such as when a user logs in]. Additionally you'll need to set these same variables in /etc/sysconfig/httpd so that they are set in Apache's environment when started by the system start-up scripts.

$ (cat << EOF
export INFORMIXDIR=/opt/informix
export DBDATE='Y4MD-'
export INFORMIXSERVER=YOURINSTANCENAME
EOF
) > /etc/profile.d/informix.sh

Text 1: Creating /etc/profile.d/informix.sh

YOURINSTANCENAME needs to be defined in /opt/informix/etc/sqlhosts. Your method of installing the SDK may or may not have set that up for you.

The system library path must also be extended to include the directories containing the SDK's libraries.

$ ( cat << EOF
/opt/informix/lib
/opt/informix/lib/cli
/opt/informix/lib/esql
/opt/informix/lib/client
/opt/informix/lib/csm
/opt/informix/lib/dmi
EOF
) > /etc/ld.so.conf.d/informix.conf

Text 2: Extending the system's library path

If the library path is not configured correctly applications, included httpd, will not be able to load the Informix libraries. At this point the library cache can be refreshed by executing the /sbin/ldconfig command. Once that has been performed either log out and back into the server, or just reboot the server, to verify that upon logging in you have the INFORMIXDIR, INFORMIXSERVER, and DBDATE variables in your enviroment.

Step#2 : Build the Informix PDO driver.

In order to build PHP PECL modules you must have php-devel, make, and gcc installed on the server.

$ pecl download PDO_INFORMIX-1.2.6
$ tar xzf PDO_INFORMIX-1.2.6.tgz
$ cd PDO_INFORMIX-1.2.6
$ phpize
$ configure
$ make

Text 3: Building PDO_INFORMIX

If your Informix SDK is installed correctly and you've properly initialized the environment everything should be found automatically and build without complaint. Now move the PDO driver into place and inform the PHP interpreter that it needs to load the library. Here we perform a dirty trick of first loading the base pdo.so library. This shouldn't be necessary and PHP will grumble about it upon initialization, but it works around some wackiness regarding PDO versions. Without this line pdo_informix.so will refuse to load because PDO isn't loaded yet because the need for PDO isn't automatically discovered.

$ cp /tmp/PDO_INFORMIX-1.2.6/modules/pdo_informix.so /usr/lib64/php/modules/
$ ( cat << EOF
extension=pdo.so
extension=pdo_informix.so
EOF
 ) >> /etc/php.d/informix.ini

Text 4: Install and register PDO_INFORMIX

Now we can try to start/restart the Apache service and see if our PDO module is available: service httpd restart. But it won't work. The loading of the Informix SDK by Apache will be blocked by SELinux's security policy.

Step#3 : Provision SELinux

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_informix.so' - libifcli.so: failed to map segment from shared object: Permission denied in Unknown on line 0

Text 4: SELinux blocking the loading of libifcli.so

This message in /var/log/httpd/error_log is indicating that loading the library failed with a "permission denied"; regardless of what you set the permissions too.

The solution is not to disable SELinux; SELinux is your over-protective big brother. Maybe annoying to have around sometimes, but worth it for those time when you need to take a short cut through a dark musty alley. The correct solution is just to label the required library as a known and approved shared library.

$ chcon -t lib_t /opt/informix/lib/cli/libifcli.so

__Text 5:___ Applying the appropriate label to libifcli.so

Step#3 : Get coffee

Restarting Apache know and you should see the pdo_informix driver available in phpinfo() output. Also double check that INFORMIXDIR, INFORMIXSERVER, and DBDATE appear in the "Enviroment" section of phpinfo; without these variables the PDO driver will not be able to find your informix instance.

From here on out it is pretty much the web developer's problem.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer