cancel
Showing results for 
Search instead for 
Did you mean: 

CentOS, sqlanywhere client for PHP - can't connect to remote server

Former Member
0 Kudos
13,600

Hy!

I have a problem that I can't seem to solve it. I was hoping for some help from here because I tried almost everything that came through my mind.

I have a fresh system of linux distribution CentOS 6.2 64bit. I installed httpd, mysql and php. Installed php client that I downloaded here (http://www.sybase.com/detail?id=1087327), added PHP extension that i downloaded here (http://www.sybase.com/detail?id=1019698) ant that should be it.

Phpinfo(); said »The SQL Anywhere client libraries could not be loaded. Please ensure that libdbcapi.so can be found in your LD_LIBRARY_PATH enviroment varible.« so i executed this:

source /opt/sqlanywhere12/bin32/sa_config.sh

Now for the funky part: PHP in HTTPD still doesn’t work, BUT if I run the script in console with:

php /var/www/html/testdb.php

it works OK

Some googling later i found that i have to add some little thing in »/etc/init.d/httpd«:

start() { 
      echo "Starting sqlanywhere variables..."
      source /opt/sybase/SYBSsa9/bin/asa_config.sh
    .
    .
}

Now, everything loads as it should, but the testdb.php doesnt work. It shows me an error:

Warning: sasql_connect(): SQLAnywhere: [-832] Connection error: Cannot create resource tree in /var/www/html/testdb.php

Or

Warning: sasql_connect(): SQLAnywhere: [-100] Database server not found in /var/www/html/testdb.php

Again, the PHP file works from console if I start the sa_config.sh before executing the script.

I’m suspecting this all has something to do with environment variables or some read/write problems. The folder /tmp looks OK so I don’t see the problem! I tried reinstalling the system, installing 32bit version but I always end up with the same error.

My connection string is:

$connection = sasql_connect("ENG=asa;DBN=*****;UID=*****;PWD=*****;COMMLINKS=TCPIP{IP=192.168.0.111;DoBroadcast=NONE};cs='utf-8'");

Please help..

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member

Is SELinux enabled? Try disabling it. It may not be an issue when you run from a console, but when apache is running as a limited user, there may be issues. If disabling SELinux helps, but you actually care about having SELinux enabled, you'll have to set up file access permissions. There is an selinux directory in your SQL Anywhere install that contains a sample policy for SQL Anywhere. It was written for RHEL 5.0, so it may be out of date for your distro.

Running the sa_config.sh script sets local environment variables in your terminal, so php within the terminal works. But the httpd server is in a different environment, probably a different user and may not be able to use the LD_LIBRARY_PATH, hence the phpinfo() error. Don't use the LD_LIBRARY_PATH at all, despite the error message.

I ran into some issues setting up sqlanywhere on linux, see: SQLAnywhere 12 on Ubuntu 11.10 linux, nginx & php

Hope it helps your CentOS config. Since setup, about 6 months ago, sqlanywhere has been running like clockwork. I use it for development daily.

chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

There is an existing discussion related to the error "cannot create resource tree".