Install PHP DB2 libraries on CentOS

We came across the requirement to manipulate DB2 using PHP scripts. In order to be able to do that you need to the DB2 libraries installed on your machine. First of all install DB2 Express ( desired version, we used 11.1 ). Make sure you are installing the development libraries with the product as you will need this when you compile the DB2 PHP libraries. Once the server is installed check out the content of the following directory /home/db2inst1/sqllib/include/ if you see a bunch of files in there you have the development pack installed and you are good to go. if you used a different instance name obviously check in there 🙂

The following command sequence will get the rest sorted, we assume you already have php installed on your machine.

  • yum install php-pear
  • yum install php-devel
  • yum install gcc
  • pecl install ibm_db2

The installer will ask where the DB2 directories are located,  just define the directory of your instance. Since we have db2inst1 as the instance the DB2 directory is located at /home/db2inst1/sqllib.

The installer will now compile the PHP libraries. Once it is done just add extension=ibm_db2.so into your php.ini file and you are good to go.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.