Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to compile with PHP4

7 views
Skip to first unread message

All_done

unread,
Apr 18, 2002, 4:27:25 AM4/18/02
to
Thanks kris

Kris Vorwerk

unread,
Apr 18, 2002, 8:56:54 PM4/18/02
to
You can find loads of helpful information on how to program with PHP at:

http://www.php.net/docs.php

Here is the odbc_connect function reference:

http://www.php.net/manual/en/function.odbc-connect.php

DSN == "data source name" or something like that, basically it's the name of the database settings that you assigned in your odbc.ini file, which you will have to setup for your particular environment. unixODBC comes with a graphical tool that can help you do this, or there are another of documents on the web that describe this file in more detail.

cheers,
-kris


> I am trying to connect to ASA ,but I don't know how to call the php
> function :
> int odbc_connect(string dsn, string user, string password, int
> [cursor_type])
>
> What is provided for the parameter "dsn" ?
> maybe ,you can give me some example .

Jekend

unread,
Apr 18, 2002, 3:14:28 AM4/18/02
to
It done .
I misspell the environment variables .
Now my apache starts .

Kris Vorwerk

unread,
Apr 18, 2002, 12:52:19 AM4/18/02
to
> I know that there are two ways to compile PHP to access ASA database ,
> one is via odbc ,the other is sybase-ct .
> I prefer the sybase-ct one .
> *BUT* I don't know how to configure php and apache to make it work .
> I am trying .
> If you have any experience ,please tell me .

This is a very common question on this newsgroup. AFAIK, ASA will support either the ODBC connections (thru the ASA native driver dbodbc.so), or TDS connections from a TDS driver (not supplied with ASA for Linux).

Personally, I would use the ODBC interface. Compile PHP with support for unixODBC, and then use unixODBC to call the ASA native, non-threaded "dbodbc7.so" driver .... Instructions on how to do this have been included at the end of this message.

I have no experience whatsoever communicating to ASA using a TDS-based driver. While it is apparently supported, I know nothing about it other than the fact that it is the "native" protocol that ASA (and ASE) support. The Microsoft SQL Server versions of this protocol introduce their own peculiarities (read: "improvements" <cough cough>) that are not compliant with the TDS 5.2 spec.

Well, okay, I know a bit more about it than the average person. For one, I strongly suspect that you can compile FreeTDS (http://www.freetds.org) and get it working with PHP, and then use the TDS interface to communicate with ASA. This might be a preferred method of communication if, for example, you want your database clients to communicate directly with a central ASA database (but the clients are of a different machine type than the dbodbc7 driver that you currently have). I'm sure that one of the ASA developers would have more to say about this aspect of the communication.

Aside: Certainly, I would be interested in seeing the source code for a TDS driver on the ASA CDs ... I think that it would really expand ASA's penetration in embedded markets by allowing any variety of clients to communicate with the DB. I point to the example where, say, a set of Motorola-based embedded clients cannot communicate directly with ASA because they have no native ODBC driver. And, an ODBC-ODBC bridge is out of the question in terms of hassle, cost, and performance. The result is that the customer may choose a different database platform -- say, MySQL -- because not only can it be compiled for any multitude of *Nix distributions but for any platform on which gcc runs, too. Summarizing, it strikes me that improving FreeTDS or making a new (similar) open-source Sybase driver and bundling it on the CD would be a win for everyone.

Back to Reality: So, overall, I'd use odbc if you weren't trying to do anything interesting with the clients that are connecting to the DB. For a simple web server + PHP + ASA setup, I'd definitely go ODBC. Here are my instructions (copied and pasted from my message in this newsgroup dated July 6, 2001):

======================================

Foreword
========
The following are my instructions on setting-up Sybase's ASA 7.0.2.1402 with
PHP 4.06 and Apache 1.3.20. These instructions focus on using ASA's
libraries
as the ODBC driver manager instead of iODBC or unixODBC. Furthermore, they
show how PHP can be compiled (and run) as a dynamic module with a number
of commonly-used features under Apache.

There are certainly trade-offs to using ASA as the driver manager; one "pro"
is that you do not have to setup or distribute unixODBC with your apps. A
"con" is that your computer would only be able to connect to ASA data
sources.
The instructions that I provide below become a bit simpler if you *do*
decide
to use a separate driver manager, since PHP would not require the additional
compile-time variables and '--custom-odbc-lib' specification.


Assumptions
===========
It is assumed that you have already installed ASA (in the directory
'/opt/asa'). Make sure that you set up the following symbolic links
in the '/opt/asa/lib' directory:

ln -s dbodbc7.so libodbc.so
ln -s dbodbc7_r.so libodbc_r.so
ln -s dbodbc7.so libodbcinst.so

Next, make sure that '/opt/asa/lib' is in your 'ld.so.conf' (and that you
have
run 'ldconfig').

For more information on installing ASA, please refer to the user manual.


Instructions
============
1) Get the PHP 4.06 source code:
http://www.php.net/downloads.php

2) Get the Apache 1.3.20 source code:
http://httpd.apache.org/dist/httpd/apache_1.3.20.tar.gz

3) Compile Apache with dynamic module support:
1. Untar the Apache source.
2. ./configure --prefix=/opt/apache --enable-module=most \
--enable-shared=max
3. make
4. make install

4) Compile PHP as a dynamic module :
1. Untar the PHP source.
2. Setup some environment variables *before* running 'configure':
CFLAGS="-DODBC_UNIX -O2" \
CUSTOM_ODBC_LIBS="-lodbc" \
LDFLAGS="-L/opt/asa/lib -lodbc"
export CFLAGS CUSTOM_ODBC_LIBS LDFLAGS

3. Some options in the PHP configuration are not necessary, but
allow
lots of interesting features. The configuration command that I
use
below should be supported on most complete Linux installations,
but may need to be modified depending on your installation
directories:
./configure --prefix=/opt/php \
--with-apxs=/opt/apache/bin/apxs \
--with-shmop \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--with-tsrm-pthreads \
--enable-trans-sid \
--with-openssl=/usr/local/ssl \
--enable-ftp \
--with-bz2 \
--with-zlib \
--with-ttf \
--enable-calendar \
--with-gettext \
--with-zlib-dir=/usr/local/lib \
--with-jpeg-dir=/usr/local/lib \
--with-tiff-dir=/usr/local/lib \
--with-png-dir=/usr/local/lib \
--without-mysql \
--with-custom-odbc=/opt/asa

At this point, you may note that I am specifically compiling-in
thread support into PHP (as is the default behaviour), although
I use ASA's non-reentrant ODBC library (libodbc.so <=>
dbodbc7.so).
This may sound somewhat dangerous, but I tried it the "right" way
previously (by linking against the reentrant library), and PHP
would constantly hang on the call to SQLConnect(). I tried it a
second time (using the non-reentrant library), and have not
experienced any problems. This is a scenario where using the
ODBC driver manager (such as iODBC or unixODBC) may solve
problems
in this regard.

4. make
5. make install
6. cp php.ini-dist /opt/php/lib/php.ini (and modify to your
liking)


5) Setup Apache to use the PHP dynamic module:
1. The installation of PHP should have modified Apache's
'httpd.conf'
file. Check out step 4a of the 'INSTALL' file in the PHP source
code for more information in this regard.

2. You will likely want to modify the 'httpd.conf' file just the way
you like. For example, you will want to change the following
options (do a search and modify the values):

ServerAdmin <=> Say, "b...@myemail.org"
ServerName <=> Say, "127.0.0.1"
DocumentRoot <=> Say, "/home/httpd"
<Directory ...> <=> Change to DocumentRoot
AllowOverride <=> Say, "AuthConfig"

(And so on ... there are a few more to change if you
chose to change DocumentRoot, as I do.)

3. Make sure that you add the following lines for the MIME types:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

6) Setup ASA's ODBC driver:
1. If left untouched, ASA's ODBC driver will check in "default"
places for the 'odbc.ini' file that specifies the ODBC DSNs that
PHP will need in order to connect. As the documents specify,
this includes ~/.odbc.ini, but probably also includes the
ASA home directories (I did not check). To override this,
thereby
letting you put the file in a more "reasonable" place, specify
the ODBCINI environment variable in your global profile:

ODBCINI = /etc/odbc.ini \
export ODBCINI

2. Now, setup odbc.ini as needed. I know very little about the
'odbc.ini' file, so I am not sure that I have ever had it set-up
perfectly, but something along the lines of this simple example
has worked for me:

[ODBC Data Sources]
PESys=

[PESys]
DatabaseName=pesys
CBSize=1460
CBSpace=200
Encryption=YES
UID=abd
PWD=sql

All done! Apache, PHP, and ASA should work without problems.

-k

Jekend

unread,
Apr 18, 2002, 12:11:01 AM4/18/02
to
I know that there are two ways to compile PHP to access ASA database ,
one is via odbc ,the other is sybase-ct .
I prefer the sybase-ct one .
*BUT* I don't know how to configure php and apache to make it work .
I am trying .
If you have any experience ,please tell me .

My Env is : RH linux 7.2 , glibc 2.2.4-13 , Apache_1.3.12 , PHP 4.1.2
ASA7

Thanks for your help .

Jekend

unread,
Apr 18, 2002, 1:33:15 AM4/18/02
to
Thanks very mach .
but I got the error message when I configure php :

"./configure: test: !=: unary operator expected
configure: error: can not run test program while cross compiling "

Jekend

unread,
Apr 19, 2002, 12:02:10 AM4/19/02
to
Thanks Kris .
I prefer to use PHP's Sybase function to make my projects be more
compatible with ASE and Mysql ...
Because the return value of ODBC function like fetch_row is quite different
with the Sybase or Mysql Function .
So , I choose freetds . Finally , I make it work .

Kris Vorwerk

unread,
Apr 19, 2002, 12:45:09 AM4/19/02
to
I'm glad to hear that FreeTDS works for you! I know that it is supposed to "in theory", but I have never used it personally. Based on your success, maybe I will try it out over the course of the summer ... ;)


Aside: ... I'm wondering if FreeTDS should be mentioned in the Sybase ASA HOWTO (if it isn't already) as an alternative to the ODBC driver for communicating with ASA for Linux? It seems to me that it's a viable open-source solution that would at least be worthwhile mentioning.

-kris

<Jekend> wrote in message news:B8060C6150F2AAA600162BE285256BA0.001F308485256B9F@webforums...

Jekend

unread,
Apr 24, 2002, 10:12:59 PM4/24/02
to
It seems that freeTDS is not so good .
I am not sure whether it is a bug of freeTDS ...
When connect failed to ASA , It will display 404 not found page ,not return
a code .
It is hard to control when I want to check the connect parameter provided .
But it is still an alternative solution to the ODBC driver .

I wonder if I can use CT-library to communicate with ASA .
I heard that it is reachable , But I couldn't find any documents about it .

Darryl

unread,
Apr 29, 2002, 4:13:04 PM4/29/02
to
Jekend wrote in message news:<32D859329B57C3E50016FB0385256B9F.0016FB5C85256B9F@webforums>...

There will soon be a third way.

I've seen the new ASA native driver for PHP that iAnywhere is working
on, beta. It works with Linux, and it seems pretty cool. I expect
they'll release it soon, unless it's already out and the net is being
abnormally silent about it.

So instead of sybase_connect(), you use sqlanywhere_connect(), and
-with sqlanywhere when you compile.

We're using PHP & ASA, converting from MS Access, & while our first db
isn't live yet, I've had the pleasure of using both ODBC & open client
on Windows & Linux to connect PHP & ASA.

Darryl

Matthieu W

unread,
Jun 5, 2002, 10:56:51 AM6/5/02
to
I've got the same error.
I've complie PHP with --with-sybase-ct option with values
/usr/local/freetds.
When I attempt toacces the php page: unable to access this page.
Same problem with iodbc (openlink)...
with
--with-sybase-ct=/opt/sybase-11.9... It's not a PHP error but a Sybase
error, the same with isql:

ASA 75 error: request start/stop database denied.

"Erreur ASA -75 : La demande de démarrage/d'arrêt de
la base de données a été
refusée
CT-LIBRARY error:
ct_connect(): protocol specific layer:
external error: The attempt to connect to the server
failed."

<Jekend> a écrit dans le message de news:
3FA999190CD7C102000C2CD485256BA6.00201B5485256BA0@webforums...

Kris Vorwerk

unread,
Jun 6, 2002, 6:09:03 PM6/6/02
to
Salut,

I'm sorry -- I'm not quite sure what your question is asking.

The message that you quoted (below) showed how I set up ASA to work with PHP
and Apache using unixODBC as the intermediate ODBC driver manager under
Linux. You should be able to use the instructions that I provided to get
ASA working with PHP+Apache under Linux.

Because I have never tried compiling unixODBC, PHP, or Apache under Windows,
I cannot guarantee that it would work -- in the very least, I'm guessing
that you would need to have a working CygWin environment set up.
Theoretically, under Windows, you may be able to configure PHP to use
Windows' driver manger (instead of unixODBC), thereby saving you the time
that you'd have to spend compiling unixODBC.

Hope this helps,
-kris


> is this methodwork for an ASA located on an NT server (so not on the unix
> machine which is installed PHP+Apache) ?
>
> "Kris Vorwerk" <no.spam...@myself.com> a écrit dans le message de
news:
> 1$L3IYp5...@forums.sybase.com...

Matthieu W

unread,
Jun 6, 2002, 8:52:43 AM6/6/02
to
is this methodwork for an ASA located on an NT server (so not on the unix
machine which is installed PHP+Apache) ?

"Kris Vorwerk" <no.spam...@myself.com> a écrit dans le message de news:
1$L3IYp5...@forums.sybase.com...

Matthieu W

unread,
Jun 7, 2002, 4:01:09 AM6/7/02
to

"Kris Vorwerk" <vor...@myself.com_NO_SPAM> a écrit dans le message de news:
1Sb5Cha...@forums.sybase.com...

> Salut,
>
> I'm sorry -- I'm not quite sure what your question is asking.
>

i would say that PHP/Apache/unixODBC are installed on the Linux machine, but
the database, ASA7, is located on a win32 machine.

I used the howto, but after compiling PHP
(--with-apxs=/usr/local/apache/bin/apxs option, so I don't have to recompile
Apache), Apache wasn't started. No errors logs. I don't know what happened.
After compiling unixODBC, I didn't see any any binary file for unixODBC like
ODBCconfig,Datamanager,odbctest. According to the howto, the php configure
option for odbc was --with-unixODBC=/usr/local but there are no binary here,
also in /usr/local/unixODBC.


Kris Vorwerk

unread,
Jun 8, 2002, 1:16:22 AM6/8/02
to
I should point out, BTW, that a number of people on this newsgroup have run
into a problem whereby they run the Windows version of ASA, but use Linux
for all of their webserver-related stuff. It would be handy if Sybase made
the Linux version of the ODBC driver available (even on the Windows
platform) -- they may already do this, I dunno. But, in the meantime, you
can always try FreeTDS instead of an ODBC-ODBC bridge. (I *highly* doubt
that you will find any open-source ODBC-ODBC bridges. Very, very, very
unlikely.) For the FreeTDS driver, check out: http://www.freetds.org.

You can even use FreeTDS with unixODBC, thereby continuing to use unixODBC
as your independent ODBC driver manager. Ultimately, you could communicate
in either of the following ways (you would have to compile the PHP and
unixODBC and FreeTDS slightly differently for each case, below):

PHP -> (ODBC) -> unixODBC -> (ODBC) -> FreeTDS -> (TDS) -> ASA7

_or_

PHP -> (TDS) -> FreeTDS -> (TDS) -> ASA7

(In each example above, the protocol used for communication is in
parentheses.)

I believe that the last method may prove a little unstable in some
circumstances. I say that because I have tried a different configuration --
using ASA's own ODBC driver directly -- with unreliable results:

PHP -> (dbodbc7.so) -> ASA7

That is why I recommend using unixODBC. And, by using FreeTDS, you become
platform independent (and not reliant directly on the Sybase drivers for
Intel/Sun/AIX machines, for example). This may or may not work for you.

regards,
-kris


> unixODBC is an ODBC driver manager. It is only capable of executing the
> ODBC driver for the platform & OS on which it is currently executing. It
> cannot send the ODBC commands to the Windows machine and have the Windows'
> ODBC driver then execute them. (To do that would require an ODBC-ODBC
> bridge, which is another "kettle of fish", so to speak.)
>
> For the functionality that you describe, the communication would look
> something like:
>
> Apache -> PHP -> unixODBC -> ODBC-ODBC Bridge -> Windows ODBC Driver ->
ASA7
>
> If you had the Linux version of ASA7 (which is the configuration that I
> described in my e-mail), the communication would look like:
>
> Apache -> PHP -> unixODBC -> used dbodbc7.so Linux driver provided with
> ASA -> ASA7
[snip]


Kris Vorwerk

unread,
Jun 8, 2002, 1:02:56 AM6/8/02
to
> i would say that PHP/Apache/unixODBC are installed on the Linux machine,
but
> the database, ASA7, is located on a win32 machine.

Hmmm....

I think that I am seeing a problem in your configuration. I assume that if
you are running ASA on the Win32 machine, you do not also have the Linux
version of ASA7. In that light, how will ODBC commands be sent from the
Linux machine to the ASA server (running on the Windows machine)?

unixODBC is an ODBC driver manager. It is only capable of executing the
ODBC driver for the platform & OS on which it is currently executing. It
cannot send the ODBC commands to the Windows machine and have the Windows'
ODBC driver then execute them. (To do that would require an ODBC-ODBC
bridge, which is another "kettle of fish", so to speak.)

For the functionality that you describe, the communication would look
something like:

Apache -> PHP -> unixODBC -> ODBC-ODBC Bridge -> Windows ODBC Driver -> ASA7

If you had the Linux version of ASA7 (which is the configuration that I
described in my e-mail), the communication would look like:

Apache -> PHP -> unixODBC -> used dbodbc7.so Linux driver provided with
ASA -> ASA7

> I used the howto, but after compiling PHP
> (--with-apxs=/usr/local/apache/bin/apxs option, so I don't have to
recompile
> Apache), Apache wasn't started. No errors logs. I don't know what
happened.

I don't believe that compiling PHP will start Apache.... As a side note: if
you read the INSTALL notes provided with PHP, you will find that you have to
edit the configuration file for Apache to your liking, and make sure that
the new PHP library that you compile is referend in the Apache conf files.
(You will probably also want to add the apache/lib directory, where your new
PHP library should be, to your ld.so.conf -- that should all be described in
the PHP INSTALL notes.)


> After compiling unixODBC, I didn't see any any binary file for unixODBC
like
> ODBCconfig,Datamanager,odbctest. According to the howto, the php configure
> option for odbc was --with-unixODBC=/usr/local but there are no binary
here,
> also in /usr/local/unixODBC.

That's correct -- there are only a few binary files for unixODBC, because
it's a library. The binary files are basically there to help you setup the
odbc.ini file and such. Otherwise, look in the ./lib of where you installed
unixODBC. (If you compiled PHP correctly, PHP will look for the ODBC
library automatically -- when it needs it. Just make sure that the ODBC
library's directory is listed in your ld.so.conf, and don't forget to rerun
ldconfig.)

Regards,
-kris


Matthieu W

unread,
Jun 10, 2002, 8:08:25 AM6/10/02
to

> I think that I am seeing a problem in your configuration. I assume that
if
> you are running ASA on the Win32 machine, you do not also have the Linux
> version of ASA7. In that light, how will ODBC commands be sent from the
> Linux machine to the ASA server (running on the Windows machine)?
>
> unixODBC is an ODBC driver manager. It is only capable of executing the
> ODBC driver for the platform & OS on which it is currently executing. It
> cannot send the ODBC commands to the Windows machine and have the Windows'
> ODBC driver then execute them. (To do that would require an ODBC-ODBC
> bridge, which is another "kettle of fish", so to speak.)
>

That's why i'v installled ASA7 for linux. But it's just for test cause I
can't force my client to buy a linux ASA licence just to acces their win
ASA.
I also installed ASE 11.9.2 for linux and try to use the CT libs as said in
a howto but it doesn't work: The win32 ASA responded with an 75 error number
(request start/top database denied), request I didn't send, just connection.


So in order to go on, I decided tu use FreeTDS: compiling and installing
worked fine but launching Apache wasn't as easy. It didd't start. I
recompiled PHP with unixODBC this time and the same problem occured. Here I
discoverd that it was the PHP module that cause the problem (by disabling
PHP in http.conf). according to Nick GORHAM from unixODBC, it's probably a
thread support problem. But when I start Apache without PHP, than I add the
PHP support in http.conf file, than I restart PHP by Apachectl restart, it
works. Maybe It work with FreeTDS.

But I still have an unixODBC problem (I rest for the moment with unixODBC
because it's compiled with now):
isql from unixODBC works fine with great env var instanced (i had to source
the asa_config.sh file which put some env var).
But not with PHP:

The PHP result is:

ODBCINI = /etc/odbc.ini
CLASSPATH =
/opt/sybase/SYBSsa7/java/jlogon.jar:/opt/sybase/shared/jConnect-5_2/classes/
jconn2.jar:$CLASSPATH
LD_LIBRARY_PATH = /opt/sybase/SYBSsa7/lib:$LD_LIBRARY_PATH

Warning: SQL error: [unixODBC][Driver Manager]Driver's SQLAllocHandle on
SQL_HANDLE_HENV failed, SQL state IM004 in SQLConnect in
/home/htdocs/test2.php on line 8

Here is my code source:

<?

echo "ODBCINI = " . getenv("ODBCINI");
echo "<br>CLASSPATH = " . getenv("CLASSPATH");
echo "<br>LD_LIBRARY_PATH = " . getenv("LD_LIBRARY_PATH");
echo "<br>";

if (!($connexion = odbc_connect("GP40","","")))
echo "<br>Connection failed";
else
{
echo "Yeah it works !";
}

?>

I've set env var by SetEnv statement in http.conf. Can I launch scripts at
apache startup (Apache must launch those scripts for its environnement) ?.
In this way i could make Apache launch a "source asa_config.sh" command at
startup.


Kris Vorwerk

unread,
Jun 9, 2002, 11:16:25 PM6/9/02
to
Here are my updated, simplified instructions on compiling PHP for use with
Apache and ASA.

In my configuration, I like to have PHP capable of using unixODBC (for ODBC
connections), as well as MySQL and Sybase (TDS) support. TDS
support is provided through FreeTDS, and can be used directly
through PHP or act as an ODBC driver that can be called by
unixODBC.

Not all of the configuration options that I used below are necessary, but
they
represent what I would consider an "average" setup. (These instructions
also
assume some familiarity with compiling and installing Linux
applications.)


1. Download the latest versions of the required software/drivers.
I used the following versions:

Apache 2.0.36
PHP 4.2.1
unixODBC 2.2.1
FreeTDS 0.53


2. Compile & install Apache. I configured with:

./configure --prefix=/opt/apache \
--enable-mods-shared=all \
--with-ssl=/usr/local/openssl


3. Compile & install unixODBC. I configured with:

./configure --prefix=/opt/unixODBC \
--disable-gui \
--disable-drivers


4. Compile & install FreeTDS. I configured with:

./configure --prefix=/opt/freetds \
--with-unixodbc=/opt/unixODBC


5. Compile & install PHP. I configured with:

./configure --prefix=/opt/php \
--with-apxs2=/opt/apache/bin/apxs \
--with-openssl=/usr/local/openssl \
--with-zlib \
--with-bz2 \
--enable-calendar \
--enable-ftp \
--enable-mbstring \
--with-mysql \
--with-ncurses \
--with-readline \
--enable-shmop \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-tokenizer \
--with-sybase-ct=/opt/freetds \
--with-unixODBC=/opt/unixODBC


6. If you do not define an ODBCINI environment variable, then unixODBC
will look for ~/.odbc.ini by default. Otherwise, you can set ODBCINI
to point to, say, /etc/odbc.ini. Make sure that your asa_config.sh
is not overriding this environment variable with something unexpected.
You will probably also want to define TDSPORT and DBLIB_PORT to be 2368.
(I do this in my /etc/profile file.) And, just to be safe, I normally
delete the /opt/freetds/etc and /opt/unixODBC/etc directories; I make
them symlinks to /etc and put all of my configuration files in there.


7. Set up your FreeTDS configuration file. Basically, you'll need to
append a short section about your server to the conf file, as in:

[pesysTDS]
host = 192.168.1.1
port = 2638
tds version = 5.0

If you want to use an interfaces file, you can define $SYBASE
as the freetds directory (/opt/freetds), then make a file
/opt/freetds/interfaces which looks like:

pesysTDS
query tcp ether 192.168.1.1 2368
master tcp ether 192.168.1.1 2368


8. Now, modify your odbc.ini file to match. (Note that the FreeTDS
driver requires a slightly different setup.) It could look like:

[pesys]
Driver = ASA
Description = Connection to my DB via ASA's ODBC driver
Trace = No
Database = pesys
UID = abd
Encryption = on
CBSize = 1460

[pesysTDS]
Driver = FreeTDS
Description = Connection to my DB via FreeTDS' ODBC driver
Trace = No
Servername = 192.168.1.1
Database = pesys
UID = abd

And, you can then define your odbcinst.ini file too look like:

[FreeTDS]
Description = FreeTDS' ODBC Driver
Driver = /opt/freetds/lib/libtdsodbc.so
FileUsage = 1

[ASA]
Description = ASA's ODBC Driver
Driver = /opt/asa/lib/dbodbc7.so
FileUsage = 1


9. Make sure that /opt/unixODBC/lib and /opt/freetds/lib are in
your ld.so.conf, and that you have run ldconfig.


======================
Tada! Now, PHP should be able to use any of the following connections:

- an ODBC connection using ASA's supplied driver
- an ODBC connection using FreeTDS's ODBC driver
- a TDS connection using the FreeTDS CT library driver
- MySQL connection (in case you get frustrated with ASA :)

I have had some difficulties connecting to my ASA server when using
FreeTDS' ODBC driver. Sometimes, it does not connect properly, and
if you specify TDSPORT but forget to specify DBLIB_PORT, you can make
it segfault. (So, caveat emptor -- it's flaky. But, according to the
docs, the DB-Lib and CT-Lib components are quite mature, so you could
always use those.) Also, I haven't had any problems using ASA 7.0.4's Linux
ODBC driver.

Cheers,
-kris

Kris Vorwerk

unread,
Jun 13, 2002, 11:25:36 AM6/13/02
to
> I also installed ASE 11.9.2 for linux and try to use the CT libs as said
in
> a howto but it doesn't work: The win32 ASA responded with an 75 error
number
> (request start/top database denied), request I didn't send, just
connection.

That's bizarre. Perhaps that problem would be better-handled on an ASE
newsgroup.


> So in order to go on, I decided tu use FreeTDS: compiling and installing
> worked fine but launching Apache wasn't as easy. It didd't start. I
> recompiled PHP with unixODBC this time and the same problem occured. Here
I
> discoverd that it was the PHP module that cause the problem (by disabling
> PHP in http.conf). according to Nick GORHAM from unixODBC, it's probably a
> thread support problem. But when I start Apache without PHP, than I add
the
> PHP support in http.conf file, than I restart PHP by Apachectl restart, it
> works. Maybe It work with FreeTDS.

It sounds like you're using a flaky PHP release -- normally, a module should
not cause the http server to die. (PHP with the new Apache 2.0.x is still
considered "experimental", in case that's what you're using.)


> Warning: SQL error: [unixODBC][Driver Manager]Driver's SQLAllocHandle on
> SQL_HANDLE_HENV failed, SQL state IM004 in SQLConnect in
> /home/htdocs/test2.php on line 8

A few things:

1) Is this error message occurring when you are using ASA's driver, or when
you are using FreeTDS through ODBC, or FreeTDS CT-Lib? FreeTDS' website
says that it's ODBC driver is still very much "alpha" code. It is better to
use the more mature CT-lib interface than to use its ODBC interface,
according to them.

2) In your ODBC DSN, if you change the driver that you are using, does this
error message still appear?

3) Sometimes, I've noticed that unixODBC doesn't like to listen to the
ODBCINI environment variable. I made my /opt/unixODBC/etc/odbc.ini file a
symlink to /etc/odbc.ini, just to be sure.

4) Just to be sure, are you running the latest release of: ASA (7.0.4),
Apache (1.3.24 or 2.0.36), PHP (4.2.1)?


> I've set env var by SetEnv statement in http.conf. Can I launch scripts
at
> apache startup (Apache must launch those scripts for its environnement) ?.
> In this way i could make Apache launch a "source asa_config.sh" command at
> startup.

I don't know; I've never had to worry about it. If you already source the
asa_config file prior to loading Apache, then Apache should inherit those
environment variables, so I'm not sure why you would want to source it
again. (I'd just call a "source asa_config.sh" from my profile or from my
bash login for an individual user on my system.)


cheers,
-kris


Matthieu W

unread,
Jun 14, 2002, 4:21:40 AM6/14/02
to
Hi!

I resolved some problem.

FreeTDS doesn't work.

unixODBC works: I tested with the isql gived bu unixODBC.

the CTlib seems to work with ASE with a great "interfaces" file: I tested
with the isql gived by ASE. The name of the pseudo-DSN (Interface file) must
be the name of the database and not of the db engine.

ASA7 client works fine too. I tested it with unixODBC. The problem was the
env var.

But the big problem is still to make toses functionnaly work with PHP.

Compile PHP with Apapche without this features: works perfectlly.
Complie PHP with unixODBC, or with sybase-ct, or both -> Apache crashes.
(core dumped)

Here is my Apache and PHP compile configuration:
APACHE:

./configure --prefix=/usr/local/apache --enable-module=most --enable-shared=
max --sysconfdir=/etc/httpd --logfiledir=/var/log/httpd --mandir=/usr/man/

PHP:
./configure --with-apxs=/usr/local/apache/bin/apxs --with-config-file-path=/
usr/local/apache/conf --with-sybase-ct=/opt/sybase-11.9.2/ --without-mysql -
-enable-ftp --enable-calendar --enable-trans-sid --enable-bcmath=yes --enabl
e-debug=no --enable-memory-limit=yes

also tested with --with-unixODBC=/usr/local


0 new messages