Jump to content

Getting Informix PDO to work in CentOS 6


Recommended Posts

Good day everybody, I am in desperate need for help trying to sort this out.

At work I was asked to install PHP and Informix on a CentOS 6 machine so they can begin developing some web projects. I've been working on it for almost a week now, but I still can't get the PDO working. I followed 3 guides already, two of which are the following:

 

http://www.whitemiceconsulting.com/2012/02/installing-pdoinformix-on-centos6.html

http://lemachete.wordpress.com/2009/06/26/instalar-pdo_informix-en-linux-centos/  [in spanish]

 

and the third one was written by a person that used to work with us and was provided by a co-worker so I can't post it here (company's property). I followed each guide to the letter, and even combined the guides trying to get informix running, but to no avail. I already formatted the machine 3 times so I can start over. So far, this is what I managed to do:

  • The environment variable INFORMIXDIR is set to /opt/IBM/informix (the same directory where I installed informix)
  • Both the pdo.so and pdo_informix.so were created in /usr/lib/php/modules
  • The following lines were added in /etc/php.ini: extension=pdo.so and extension=pdo_informix.so
  • I have a user called informix
  • Just in case, I also added the following line to the pdo.ini file in /etc/php.d: extension=pdo_informix.so

I also modified some other files like the /etc/init.d/httpd and the /etc/profile but as far as I know, just doing the above should be enough to get the Informix PDO up and running.

 

However, if I try to run this program:

<?php
echo '<h3>Available PDOs:</h3>';
foreach (PDO::getAvailableDrivers() as $driver)
{
        echo $driver . '<br/>';
}
?>

All I get as a result is:

 

Available PDOs:

 

sqlite

 

Checking the phpinfo() confirms that only the SQLite PDO is loaded. Also if I try to access the server using $db = new PDO(); sentence, I get this error:

 

[Thu Sep 26 11:36:21 2013] [error] [client 127.0.0.1] PHP Fatal error:  Uncaught exception 'PDOException' with message 'invalid data source name' in /var/www/html/informixTest.php:22\nStack trace:\n#0 /var/www/html/informixTest.php(22): PDO->__construct('informix=148.23...', 'informix', '1nf0rm1x123')\n#1 {main}\n  thrown in /var/www/html/informixTest.php on line 22

 

I already tried everything I've found on the web, but nothing works. Can somebody please help me sort this out? What am I doing wrong?

 

PS: just in case anybody wonders, I did restart apache after applying any modification to the PHP configuration. I also checked if there is another php.ini file that is overriding the one I modified, but there is none.

Link to comment
Share on other sites

What's my suggestion to you, if mac's suggest doesn't work is to download a pdo_informix driver and place it to php.x.version/ext directory. Then, just compile that version of php from source code. 

Check for available options:

cp -R PDO_INFORMIX-1.3.0/* path_to_php_library/ext/pdo_informix

./configure --help

./configure --with-pdo-informix=/DIR // it's a directory of this database

pdo_informix

Edited by jazzman1
Link to comment
Share on other sites

@mac_gyver: OK I found something important. I checked the /var/log/httpd/error_log and browsed carefully through today's logs and discovered this error:

 

[Fri Sep 27 09:21:20 2013] [notice] Digest: done
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo_informix.so' - libifcli.so: failed to map segment from shared object: Permission denied in Unknown on line 0
PHP Warning:  Module 'PDO' already loaded in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo_informix.so' - libifcli.so: failed to map segment from shared object: Permission denied in Unknown on line 0

 

Following the instructions from http://www.whitemiceconsulting.com/2012/02/installing-pdoinformix-on-centos6.html again I realized that SELinux wouldn't allow me to load certain modules, so I ran this command:

 

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

 

and then restarted apache. Checking the error log after that, I found that a similar error emerged, but this time with a different module, so I'll just keep running that command for each module that fails to load. I'll let you know if, after clearing all these errors, I can finally get informix up and running. Thanks for your advice.

Link to comment
Share on other sites

Nice, I finally got informix PDO running :3

Both my little script and phpinfo() confirm that Informix PDO was loaded successfully.

But, when I try to run another test program that should connect to a database and display a table of data I get this new error:

 

[Fri Sep 27 11:28:30 2013] [error] [client 127.0.0.1] PHP Fatal error:  Uncaught exception 'PDOException' with message 'invalid data source name' in /var/www/html/informixTest.php:6\nStack trace:\n#0 /var/www/html/informixTest.php(6): PDO->__construct('informix=148.23...', 'informix', '1nf0rm1x123')\n#1 {main}\n  thrown in /var/www/html/informixTest.php on line 6

 

However, it seems that the cause for this error is that I didn't configured the hosts correctly and I'm currently working on that. Anyhow, I want to

thank you again for your advice :3

Next time, I'll pay more attention to what error logs say :P

Link to comment
Share on other sites

He-he...good job :)

You have to know, that SELinux doesn't allow the httpd daemon to "talk" to the LDAP server on the CentOS(RedHat) machines. So, you should care about that very well.
Otherwise, a lot of php functions won't work, like mkdir(), mail(), copy(), move_uploaded_file() and so on!

Edited by jazzman1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.