Ubuntu – Sybase – PHP not able to connect

All we need is an easy explanation of the problem, so here it is.

I’m trying to connect Sybase 17 from PHP(7.4, 8.0) Laravel running on apache2 on Ubuntu(18.4) system. We are using SQL Anywhere. Sybase is not installed on the same server.

We are getting this error – Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can’t open lib ‘/opt/sqlanywhere17/lib64/libdbodbc17_r.so’ : file not found, SQL state 01000 in SQLConnect in /var/www/html/sybaseconnection.php on line 14

We’ve already performed the below steps:

  1. Already verified libdbodbc17_r.so file is there.
  2. Necessary permission is already given.
  3. Able to connect using Telnet and command line to SQL Anywhere 17.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

It can probably not load the file, since that file has some more dependencies.

I would suggest to do these two things:
Include the content of /opt/sqlanywhere17/bin64/sa_config.sh into /etc/apache2/envvars

and

Create a file /etc/ld.so.conf.d/sqlanywhere17.conf with this content

/opt/sqlanywhere17/lib64
/opt/sqlanywhere17/resr

Then restart apache and it should be able to connect

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply