Skip to content

Instantly share code, notes, and snippets.

@bironeaj
Last active April 13, 2024 03:26
Show Gist options
  • Save bironeaj/c1fd534f6852f0b0510e894520393821 to your computer and use it in GitHub Desktop.
Save bironeaj/c1fd534f6852f0b0510e894520393821 to your computer and use it in GitHub Desktop.
Ubuntu IBM DB2 ODBC + CLI + PHP PDO Installation Instructions/Script - Tailored for Laravel Forge
# Install Dev Package
sudo apt install php7.2-dev
# CD Home
cd ~
# Get CLI
wget -q -O CLI.tar.gz https://iwm.dhe.ibm.com/sdfdl/v2/regs2/smkane/IDSOC/Xa.2/Xb.bL-snMrfTDtX6PgwwuXqAdeiFX6UY09DUuicweVTRlk/Xc.ibm_data_server_driver_for_odbc_cli_linuxx64_v11.1.tar.gz/Xd./Xf.LPr.D1vk/Xg.9810279/Xi.swg-idsoc97/XY.regsrvs/XZ.42v0ODLDocGa6RjgsAKBjJobG6U/ibm_data_server_driver_for_odbc_cli_linuxx64_v11.1.tar.gz
# Get PDO
wget -q -O PDO.tar.gz https://pecl.php.net/get/PDO_IBM-1.3.5.tgz
# Unpack Files & Cleanup
tar -zxf CLI.tar.gz
rm CLI.tar.gz
tar -zxf PDO.tar.gz
rm PDO.tar.gz
# Install CLI
sudo mkdir /opt/ibm/
sudo mv clidriver /opt/ibm/cli
sudo cp -r /opt/ibm/cli/lib /opt/ibm/cli/lib64
# Set CLI ENV Variables
sudo bash -c 'cat <<EOT>> /etc/profile
DB2_CLI_DRIVER_HOME=/opt/ibm/cli
DB2CLIINIPATH=/opt/ibm/cli/cfg
PATH=\$PATH:/opt/ibm/cli/bin
LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/ibm/cli/lib64
EOT'
source /etc/profile
sudo bash -c 'cat <<EOT>> /etc/ld.so.conf.d/db2.conf
/opt/ibm/cli/lib64
EOT'
sudo ldconfig
# Configure CLI
db2cli writecfg add -dsn (WRKRDBDIRE entry) -database (WRKRDBDIRE entry) -host XXX.XXX.XXX.XXX -port 446 -parameter "IsolationLevel=32"
db2cli bind "/opt/ibm/cli/bnd/@db2cli.lst" -dsn (WRKRDBDIRE entry) -user USER -passwd PASS -options "blocking all grant public"
# Install PDO
cd ~/PDO_IBM-1.3.5
sudo phpize7.2
sudo mkdir -p include/php/20170718/ext
sudo cp -r /usr/include/php/20170718/ext/. include/php/20170718/ext/
sudo ./configure --with-pdo-ibm=/opt/ibm/cli
sudo make
sudo make install
# Cleanup
cd ~
sudo rm -rf PDO_IBM-1.3.5
sudo rm package.xml
# Edit php.ini extension=pdo_ibm.so
sudo bash -c 'cat <<EOT>> /etc/php/7.2/cli/php.ini
extension=pdo_ibm.so
EOT'
sudo bash -c 'cat <<EOT>> /etc/php/7.2/fpm/php.ini
extension=pdo_ibm.so
EOT'
# Restart PHP
sudo service php7.2-fpm restart
# Restart nginx
sudo service nginx restart
@bironeaj
Copy link
Author

bironeaj commented Jun 26, 2018

Changes needed to make script run in your env;

  1. Home dir
  2. Line 29 & 30 add DB, IP, Port(if needed), Username, Password

Inspired by;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment