Teradata ODBC driver with Apache/PHP


Teradata ODBC driver with Apache/PHP

Has anyone successfully setup and run an Apache/PHP environment with the Teradata ODBC driver?

I can get everything running, but odbc_connect() PHP calls result in segfaults in Apache. It's strange, because running php from the command line with the same php script works fine. Looking at the trace files, it looks like the authentication step is happening, and then poof.

Any ideas of things to try?
Not applicable

Re: Teradata ODBC driver with Apache/PHP

I have XAMPP installed on my windows desktop and the odbc_connect with PHP works okay. I tried to run odbc_connect from Linux and got an error via the command line. I haven't tried the XAMPP install on Linux yet.

Re: Teradata ODBC driver with Apache/PHP

I'm not sure why (though I think it has something to do with easing filesystem access restraints), but setting the Apache directive CoreDumpDirectory makes the setup work.

Re: Teradata ODBC driver with Apache/PHP

Ok, so here's my setup.
Redhat ES 5
Apache 2.2
Php 5.14
odbc 2.21
Teradata driver 8.1....all rpms installed.

when I run isql -v dbname dbuser dbpassword , I get this
[ISQL]ERROR: Could not SQLConnect

through php -> odbc_connect("edw_prod", "user", "password")
I get this...popped into the apache error_log
PHP Warning: odbc_connect() [ ]: SQL error: , SQL state 00000 in SQLConnect in

(also the same for the user's .odbc.ini)

InstallDir = /usr/odbc
Trace = Yes
TraceDll = /usr/odbc/lib/odbctrac.so
TraceFile = /edw/trace.log
TraceAutoStop = 0

[ODBC Data Sources]
default = tdata.so
edw_prod = tdata.so

Driver = /usr/odbc/drivers/tdata.so
Description = EDW PROD 5380
DSNTraceEnable = Yes
DBCName = serverIP
LastUser =
Username = user
Password =
Database = prod
DateTimeFormat = AAA
SessionMode = ANSI

Teradata = Installed
Trace = Yes
UsageCount = 4

Driver = /usr/odbc/drivers/tdata.so
UsageCount = 2
ConnectFunctions = YYY
DriverODBCVer = 3.51
SQLLevel = 1


Guys, need your help ! been struggling in getting this working for over 3 days now.

Re: Teradata ODBC driver with Apache/PHP

no one have a setup like this at all???
Linux/apache/php ?
bunch of winblows users on here or what?

Re: Teradata ODBC driver with Apache/PHP

My guess would be the programs are not finding the odbc files correctly. Use 'strace' to run isql and carefully look at the strace output to see if there are some necessary file isql can not find. This will take you time.

Re: Teradata ODBC driver with Apache/PHP

Hi, did you ever get the ODBC connection to Teradata from Apache and PHP to work? I am trying to do the same thing. I can use isql to connect to Teradata from the linux box and pull data, and I can run Teradata's 'adhoc' program and connection and pull data. But I cannot get php's odbc_connect() function to work. Looking at the detailed trace, it looks like somethign with the authentication, though I am properly passing username and password.

Teradata Employee

Re: Teradata ODBC driver with Apache/PHP

Here is some information, how to build/install/configure and when Apache executes PHP as CGI binary :

It is important to build PHP against the DataDirect driver manager that is distributed with Teradata ODBC driver. For that reason make sure ODBC_HOME environment variable points to a correct folder. (showed below)

PHP configure looks header file odbc.h in the ODBC driver includes directory. So, make sure to create the header file with the file name odbc.h and add following lines in the file and save it:

#include <odbcinst.h>
#include <sql.h>
#include <sqlext.h>

(below steps used php ver 5.3.3)

> tar -xzf php-5.3.3.tar.gz
> cd php-5.3.3
> export ODBC_HOME=/opt/teradata/client/ODBC_32
> export CPPFLAGS="-I$ODBC_HOME/include"
> export CUSTOM_ODBC_LIBS="-L$ODBC_HOME/lib -lodbc -lodbcinst"
> ./configure --prefix=/usr/local/php --with-custom-odbc=$ODBC_HOME
> make <-- build
> make install <-- install

below are optional.

> php-cgi –v <-- to verify installation of PHP
> php-cgi –info <-- to see configuration information

Configuration of Apache server is controlled with httpd.conf file. Update the file to add support for PHP CGI scripts as follows:
Define a PHP CGI script directory alias, mapping an Apache document directory to a real directory where php-cgi binary is located. Inside <IfModule alias_module> section, add the following line to define a PHP CGI script directory alias:

> ScriptAlias /cgi-bin-php/ "/usr/local/php/bin/"

In the root of the document (outside of any section) add this access control section for this directory as:

<Directory "/usr/local/php/bin">
SetEnv ODBCINI "/ opt/teradata/client/ODBC_32/odbc.ini"
SetEnv ODBCINSTINI "/opt/teradata/client/ODBC_32/odbcinst.ini"
Options Indexes FollowSymlinks
AllowOverride None
Options None
Order allow,deny
Allow from all

Inside <IfModule mime_module> section, add the following to define a new MIME type to support the .php file extension. Next add “Action” entry to tell Apache to serve the new MIME type with php-cgi binary located in the directory alias /cgi-bin-php/:

AddType application/x-httpd-php .php
Action application/x-httpd-php "/cgi-bin-php/php-cgi"

Note the definition of ODBCINI and ODBCINST environment variables. Those variables are passed into PHP process during request handling. Alternatively, those variables can be defined within PHP script itself:


Restart the server:

> /usr/local/apache2/bin/apachectl restart

Re: Teradata ODBC driver with Apache/PHP


Junior Supporter

Re: Teradata ODBC driver with Apache/PHP

Any suggestions for this error I am getting?

PHP Warning:  odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/opt/teradata/client/ODBC_32/lib/tdata.so' : /opt/teradata/client/ODBC_32/lib/tdata.so: wrong ELF class: ELFCLASS32, SQL state 01000 in SQLConnect in /home/username/helloWorld.php on line 8

PHP Warning:  odbc_exec(): supplied argument is not a valid ODBC-Link resource in /home/username/helloWorld.php on line 10