Search code examples
phpmysqlpdodb2ibm-midrange

PHP to AS400 Connection via ODBC/PDO error from browser


I am trying to establish a connection between a linux server and our AS400 to query the DB2 database. I installed and configured both unixODBC and the iSeries Access drivers. When using isql with a DSN specified in /etc/odbc.ini the connection goes through fine. When I run php -f connect.php the connection works as well, but when I browse to http://localhost/connect.php i get the following message:

exception 'PDOException' with message 'SQLSTATE[01000] SQLDriverConnect: 0 [unixODBC][Driver Manager]Can't open lib '/opt/ibm/iSeriesAccess/lib64/libcwbodbc.so' : file not found' in /srv/http/connect.php:25 Stack trace: #0 /srv/http/connect.php(25): PDO->__construct('odbc:DRIVER={iS...', '', '') #1 {main}

I am assuming it must be a permission issue... But I am not sure how to go about it. Any ideas? Thank you.


Solution

  • OK, I found the solution and I'll post it for anyone who needs it.

    Creating a symbolic link to the driver files in /usr/lib/ solves the issue.

    sudo ln -s /opt/ibm/iSeriesAccess/lib64/* /usr/lib/*

    After that Apache/PHP will be able to locate the file without hiccups.

    Hope it helps.