Skip to content

Instantly share code, notes, and snippets.

@eSkiSo
Created August 9, 2024 12:55
Show Gist options
  • Save eSkiSo/daa3b9c4488969d4137d42b35ea426b5 to your computer and use it in GitHub Desktop.
Save eSkiSo/daa3b9c4488969d4137d42b35ea426b5 to your computer and use it in GitHub Desktop.
Install IBM DB2 in PHP8 (8.2)

Install IBM DB2 on Ubuntu with PHP 8.2 (or others)

Step 1

Check if Cli Driver link is still the same:

https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz

//see all
https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/

Step 2

Unzip to /opt/clidriver

sudo mkdir /opt/clidriver
cd /opt/clidriver/
sudo wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz
sudo tar -zxvf linuxx64_odbc_cli.tar.gz

Step 3

Add path

export IBM_DB_HOME=/opt/clidriver 
export LD_LIBRARY_PATH=/opt/clidriver/lib
export PATH=/opt/clidriver/bin:$PATH

Step 4

Install php module from pecl

sudo pecl -d php_suffix=8.2 install ibm_db2

When/if it asks for a folder type:

/opt/clidriver

Step 5

Add to PHP

sudo nano /etc/php/8.2/mods-available/ibm_db2.ini

And add:

; configuration for php imb_db2 module
; priority=20
extension=ibm_db2.so

Step 6

Activate in PHP

sudo phpenmod ibm_db2

Step 7

Restart apache

sudo systemctl restart apache2

Step 8

Check if it loaded

php -i | grep ibm_db2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment