Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OFF] Ubuntu/CentOS ODBC Driver #40

Closed
douglasjunior opened this issue Jun 8, 2018 · 11 comments
Closed

[OFF] Ubuntu/CentOS ODBC Driver #40

douglasjunior opened this issue Jun 8, 2018 · 11 comments

Comments

@douglasjunior
Copy link

douglasjunior commented Jun 8, 2018

I was able to work with this library on Windows (XAMPP) with the ODBC Driver iSeries.

Now I need to deploy the project in production, and I would like it to be on Linux. The company support team only has one Ubuntu 11 VM with the ODBC Driver installed successfully. According to them it was not possible to install the driver in newer versions or other distributions.

My question: What is the ODBC Driver, and which Linux distribution/version are you using?

My server is an AS/400 late 2009.

@wolojonathan
Copy link

wolojonathan commented Jun 15, 2018

Hi Douglas,

I've been struggling for the past weeks with the ODBC drivers on Linux. Personally, I succeeded to install the iSeries ODBC on a CentOS 7 VM, and I've been using the old "iSeriesAccess-6.1.0" driver.

It's working up to some extent, and it might work in scope of laravel-db2.
However, the SQL relay I'd like to set up (my other personal project) is not compatible with that driver version. because of some faulty behavior in some cases.
According to what I found on the web, I need the new one called "iAccess" (IBM_i_Access_Client_Solutions_-_Linux_AP_LCD8).

If by any chance, you have an access to the IBM ESS with a product giving you access to that new client, could you please send me an email ? I'm really desperate to find that one for a long time already

If you need the drivers I'm using for CentOS, please contact me by email as well, I'll be glad to share.

Have a nice day

@bironeaj
Copy link
Contributor

Hello,

Just a question, why are you guys using the ODBC driver and not the PHP PDO? The only reason I can think of is licensing?

Anyway, the PDO is much easier to configure. I created a gist with my install script for the IBM driver and the PDO. You can find that script here. The script was made for Ubuntu/Laravel Forge but it should be a good starting point.

Hope this helps!

@nulele
Copy link

nulele commented Oct 24, 2018

Hi @bironeaj,
I'm interested in your approach. Can you please post what's your database.php configuration for ibmi connection?
Many thanks!

@bironeaj
Copy link
Contributor

@douglasjunior
Copy link
Author

douglasjunior commented Oct 26, 2018

@wolojonathan, in the end I was able to update Ubuntu 11 where there was the old ODBC already installed. So I did not need to reinstall the driver.

@bironeaj, what do I need to install on Linux to work this way? Is your DB2 an as400?

@bironeaj
Copy link
Contributor

bironeaj commented Oct 26, 2018

@douglasjunior I wanted to let you know the driver will run on the latest Ubuntu and CentOS. As mentioned before, here is the install steps I go thru for setting up a Laravel Forge server. You should be able to adapt it for your needs. It is an iSeries/AS400.

@douglasjunior
Copy link
Author

Thanks, I think the issue can be closed now.

@douglasjunior
Copy link
Author

Just to document, I'll add the script here. Thanks @bironeaj!

# 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
Contributor

@douglasjunior No problem. The URL on line 6 will need updated. IBM signs the download URL. You will have to login to IBM and get a new URL.

@nulele
Copy link

nulele commented Oct 26, 2018

@nulele here you go https://gist.github.com/bironeaj/4008e98921dddde46792488c21cb91a1

Thank you @bironeaj!!

Just on doubt... if you already define IP, username and password in the script, why declaring them again in the laravel driver configuration?

@bironeaj
Copy link
Contributor

@nulele Different developers have different logins... Helps maintain the Laravel way of doing versioning on the DB tables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants