DB2, Linux and PHP

If you want to use DB2 as a back end database for PHP, then you have to do the following.

If you have not allready installed Apache and PHP, you do it with


sudo apt-get install php5 php5-dev php5-gd php-pear

If you allready have Apache and PHP installed, then install just php-pear (unless it also is already installed). Now you can download, compile and install db2-module for PHP. You must have working internet connection to do this. Execute command


sudo pecl install ibm_db2

Script asks path to existing DB2 installation. The path you should give is


/home/db2inst1/sqllib

If compilation and installation was successful there is one last step. You have to modify the file /etc/php5/apache2/php.ini and add there following lines in the Extensions section


extension=ibm_db2.so
ibm_db2.instance_name=db2inst1

Then restart Apache with


sudo /etc/init.d/apache2 restart

Leave a comment

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 105 other subscribers