cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble getting PHP working with SQL Anywhere16 under Linux/Ubuntu

6,810

Hi,

My stack is:

Ubuntu 14.04 x64 (headless - shell access only)
SQL Anywhere 16 Developer Edition (I believe build 2043)
  (sqla16developerlinux.tar.gz, md5: 3e64a95cfb5704553a070d81d4195369)
PHP Version 5.5.9-1ubuntu4.5
nginx web server

I can get the SA16 PHP extension loading successfully, but when I activate libdbcapi.so, the PHP script crashes PHP and the browser shows "502 Bad Gateway" error from nginx.

Here are the steps I've done:

A. Created PHP script that executes phpinfo() and verified it runs successfully from my browser. This shows that the PHP/nginx part of the installation is working.

B. Copied the newest sa16 php extension files to the PHP extension directory, added the appropriate entry to php.ini, and restarted php:

sudo cp /opt/sqlanywhere16/lib64/php-5.5.0_sqlanywhere*.so /usr/lib/php5/20121212/
sudo vim /etc/php5/fpm/php.ini
<added the following line>
  extension=php-5.5.0_sqlanywhere.so
sudo service restart php5-fpm
Reloaded the browser window and now phpinfo() shows sqlanywhere loaded successfully, but without access to libdbcapi.so:
PHP SQLAnywhere driver version: 2.0.13.1
SQLAnywhere client version: The SQLAnywhere client libraries could not be loaded.
Please ensure that libdbcapi.so can be found in your LD_LIBRARY_PATH environment variable.
C. Created a new .conf file for ldconfig pointing to /opt/sqlanywhere16/lib64, updated ldconfig and restarted php:
sudo vim /etc/ld.so.conf.d/sqlanywhere.conf
<with the single line>
  /opt/sqlanywhere16/lib64
sudo ldconfig
sudo service restart php5-fpm
But now, when I run the PHP phpinfo() script in the browser, PHP crashes and I get
502 Bad Gateway

I suspect this may be some sort of version mismatch problem, but I'm using only the files that came with the distro. Does anyone have a suggestion as to what I might try next?

UPDATE: As a final step, I needed to add an entry to /etc/php5/fpm/pool.d/www.conf and restart php:

sudo vim /etc/php5/fpm/pool.d/www.conf
<add the line>
  env[LD_LIBRARY_PATH] = /opt/sqlanywhere12/lib64
sudo service restart php5-fpm

Now things work properly!

Thanks, Terry

View Entire Topic

Probably not cool to answer one's own question, but I did figure out the problem.

As a final step, I needed to add an entry to /etc/php5/fpm/pool.d/www.conf and restart php:

sudo vim /etc/php5/fpm/pool.d/www.conf
<add the line>
  env[LD_LIBRARY_PATH] = /opt/sqlanywhere12/lib64
sudo service restart php5-fpm
I will edit the original post appropriately.

Breck_Carter
Participant

It is perfectly cool to answer your own question; this is not StackOverflow, there are no Antwort Betreuer squads here.

VolkerBarth
Contributor

Antwort Betreuer

So that's another expression borrowed from German? Is that supported by SAP?

Volker the Besserwisser