Skip to content

Instantly share code, notes, and snippets.

Last active Oct 22, 2018
What would you like to do?
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
# Get PDO
wget -q -O PDO.tar.gz
# 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
source /etc/profile
sudo bash -c 'cat <<EOT>> /etc/
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
sudo bash -c 'cat <<EOT>> /etc/php/7.2/cli/php.ini
sudo bash -c 'cat <<EOT>> /etc/php/7.2/fpm/php.ini
# Restart PHP
sudo service php7.2-fpm restart
# Restart nginx
sudo service nginx restart

This comment has been minimized.

Copy link
Owner Author

@bironeaj 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