Skip to Content.
Sympa Menu

freetds - Re: [freetds] mssql_connect fails with PHP 4.3.4 on RH Linux 9

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Daniel Fazekas <fdsubs AT axelero.hu>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] mssql_connect fails with PHP 4.3.4 on RH Linux 9
  • Date: Tue, 2 Dec 2003 22:47:32 +0100

On Dec 2, 2003, at 21:11, James McGowan wrote:

You ignored my best idea to try. Don't. :)

Could you try a short test without Apache?

Just create a short .php script which doesn't assume it's a web page,
and test if from the command-line:

php testscript.php

This should help narrow down the problem a lot.

1. "dump file = /var/log/freetds", and
2. "/var/log/freetds" is a filename, and
3. the process has permission to write to "/var/log",

1. is correct
2. is correct
3. Apache or PHP? Apache writes its own access_log to /var/log, and I have a mod_php_error log that writes there as well. Neither log file reveals anything of interest.

When you are running PHP from the command line, PHP has the access privileges of your shell. When it's run via Apache, it shares Apache's privileges.

That other processes can write to other log files doesn't mean anything.

Usually, /var/log is owned by root:root and only root can write there.
To let specific non-root processes write their own log files there, the common method is to pre-create (as root) either a subdirectory or a file for them, then that file or subdirectory's owner is changed to the process' UID.

Try:
[fds@fds fds]$ ls -lad /var/log
drwxr-xr-x 8 root root 4096 Dec 1 04:02 /var/log

Apache, I believe, keeps it's root credentials to write the log files, but FreeTDS won't have that.

So you can just pre-create the log file by issuing

touch /var/log/freetds

and then change it's owner to

chown apache /var/log/freetds

Depending on what user apache is impersonating.
Check
ps waux | grep httpd

The very first word per line will be the user name. The very first httpd process will be running as root, and all the others as something else. That's the one you need.


By running tsql and making it create the log file, the file probably already exists with root or your personal user's rights, giving apache-php-freetds no access to write to it.


ldd reports:
libsybdb.so.3 => /usr/local/freetds/lib/libsybdb.so.3 (0x4004a000)
I'm not into this stuff enough to understand why there are so many references to sybase and sybdb libraries in freetds. I understand Sybase corp's relationship to MS SQL Server and that they produced free drivers for *nix early on, but now I'm confused about what config options I should be using.

That's perfect. FreeTDS originated as a replacement / enhancement of the closed-source Sybase libraries. To make it work with existing programs which used the older Sybase libraries, the file names and interfaces were kept the same.

Some notes say to build freetds with "--with-sybase=/usr/local/freetds"

Those are old notes. Pre-4.3.0 of PHP --with-mssql wasn't available on *nix.

I thought that by using "--with-mssql=/usr/local/freetds" that
I would be eliminating all references to sybase ct-libs. But alas...

But alas, as you can see, you did eliminate them. That's the dblib, not the ct-lib.

--with-mssql and --with-sybase use the dblib and only --with-sybase-ct uses the ct-lib.

It wouldn't make much sense to use --with-sybase now for MSSQL, but you can still use --with-sybase-ct if for some reason you want PHP to use the ctlib instead. Before 4.3.0, --with-sybase-ct was the preferred way.

--with-mssql gets you some mssql extras, but the basics are there with sybase-ct as well. (mssql_connect(), mssql_query() etc)
The most noticeable difference is that your PHP warning/error messages relating mssql would start with "Sybase:" instead.

There's no such thing as "--enable-mssql"

Good point, although I've seen it in other folk's configs. I figure it couldn't hurt. I've recompiled without it since my first post and seen no effect.

Of course not. You can specify --make-this-damned-thing-work too and ./configure will be happy to ignore it without any complaints.

What's --enable-dbmfix supposed to do?

Daniel reports that this is an obsolete switch. I didn't use it in the latest build.

That's James who knew what this used to be. I don't know that much about FreeTDS, I'm just a fellow user trying to help.

--
Daniel





Archive powered by MHonArc 2.6.24.

Top of Page