[unixODBC-support] Doing a SQLDriverConnect fails in Apache with Error 500: "Internal Server Error"

Miguel Rentes miguel.rentes at efacec.pt
Tue Jun 3 14:34:22 BST 2008


Hi Stefan,

I have a printenv.cgi that I used before to see the environment 
variables I have when I make a request with the web browser. Here is the 
output:

DOCUMENT_ROOT="/home/scatex/dsv/sxbin/weblists/htdocs"
GATEWAY_INTERFACE="CGI/1.1"
HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_CHARSET="ISO-8859-1,utf-8;q=0.7,*;q=0.7"
HTTP_ACCEPT_ENCODING="gzip,deflate"
HTTP_ACCEPT_LANGUAGE="pt-pt,pt;q=0.8,en;q=0.5,en-us;q=0.3"
HTTP_CACHE_CONTROL="no-cache"
HTTP_CONNECTION="keep-alive"
HTTP_COOKIE="PHPSESSID=ca37dscif7aeffg42pfn9f45o3"
HTTP_HOST="172.18.200.153:8080"
HTTP_KEEP_ALIVE="300"
HTTP_PRAGMA="no-cache"
HTTP_USER_AGENT="Mozilla/5.0 (X11; U; Linux i686; pt-PT; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5"
LD_LIBRARY_PATH="/home/oracle/apache/lib:/home/oracle/apache/lib:/home/oracle/oraHome1/lib:/usr/local/lib:/home/scatex/dsv/sxbin"
ODBCINI="/usr/local/etc/odbc.ini"
ODBCINSTINI="/usr/local/etc/odbcinst.ini"
PATH=".:/usr/java/j2sdk1.4.2_09/bin:/usr/sbin:/etc:/bin:/usr/bin:/usr/local/bin:/usr/local/lib:/usr/X11R6/bin:/home/scatex/dsv/sxbin:/home/scatex/dsv/sxbin/scripts:/home/scatex/dsv/sxbin/grafs:/home/scatex/dsv/scatex/synoptic:/home/scatex/dsv/scatex/libsyno:/usr/xrt/bin:/home/oracle/oraHome1/bin"
QUERY_STRING=""
REMOTE_ADDR="172.18.200.62"
REMOTE_PORT="43898"
REQUEST_METHOD="GET"
REQUEST_URI="/cgi-bin/printenv.cgi"
SCRIPT_FILENAME="/home/scatex/dsv/sxbin/weblists/cgi-bin/printenv.cgi"
SCRIPT_NAME="/cgi-bin/printenv.cgi"
SERVER_ADDR="172.18.200.153"
SERVER_ADMIN="you at example.com"
SERVER_NAME="172.18.200.153"
SERVER_PORT="80"
SERVER_PROTOCOL="HTTP/1.1"
SERVER_SIGNATURE=""
SERVER_SOFTWARE="Apache/2.2.8 (Unix) PHP/5.2.6"
TZ="PORST-0PORDT-1,M3.5.0/01:00,M10.5.0/03:00"
XAPPLRESDIR="/home/scatex/dsv/sxcli/resources_UK"

As you can see from LD_LIBRARY_PATH I have all the search path I need. I 
compiled the .cgi with "cc -o testeODBC.cgi testeODBC.c -lodbc" 
(libodbc.so is in /usr/local/lib) and it works from the command line 
environment.

I'm afraid it isn't a search path problem. I've also checked 
/etc/ld.so.conf and it has /usr/local/lib (and also added 
/home/oracle/oraHome1/lib and did a ldconfig) but restarting apache 
didn't do the job.

Any more ideas on what can be the source of the problem?

Regards,

Miguel Rentes

Stefan Radman wrote:
> If it works from the command line and doesnt work from a daemon it is 
> often due to different environments.
> I would guess that you lack a library search path for loading Oracle 
> libraries required by /home/oracle/oraHome1/lib/libsqora.so.10.1
>  
> Stefan
>
>     ------------------------------------------------------------------------
>     *From:* unixodbc-support-bounces at easysoft.com
>     [mailto:unixodbc-support-bounces at easysoft.com] *On Behalf Of
>     *Miguel Rentes
>     *Sent:* Tuesday, 03 June, 2008 12:34
>     *To:* unixodbc-support at easysoft.com
>     *Subject:* [unixODBC-support] Doing a SQLDriverConnect fails in
>     Apache with Error 500: "Internal Server Error"
>
>     Hi everyone!
>
>     I'm trying to create a .cgi that makes a connection to Oracle
>     Database using unixODBC (in a Red Hat Enterprise Linux 4 machine).
>
>     I've successfully compiled Apache (APR 1.2.12, APR-Util 1.2.12,
>     HTTPD 2.2.8), unixODBC (2.2.12) and PHP (5.2.6) but when I try to
>     run the cgi from the web browser I get "Internal Server Error". If
>     I run the same cgi from command line it works wih no errors.
>
>     Here is my actual configuration:
>
>     /usr/local/etc/odbc.ini:
>
>     [SXDB]
>     Application Attributes        = T
>     Attributes        = W
>     BatchAutocommitMode        = IfAllSuccessful
>     CloseCursor        = T
>     DisableDPM        = F
>     DisableMTS        = T
>     Driver        = ORACLE_ODBC_Driver_Linux_ora10g
>     DSN        = SXDB
>     EXECSchemaOpt        =
>     EXECSyntax        = T
>     Failover        = T
>     FailoverDelay        = 10
>     FailoverRetryCount        = 10
>     FetchBufferSize        = 64000
>     ForceWCHAR        = F
>     Lobs        = T
>     Longs        = T
>     MetadataIdDefault        = F
>     QueryTimeout        = T
>     ResultSets        = T
>     ServerName        = SXDB
>     SQLGetData extensions        = F
>     Translation DLL        =
>     Translation Option        = 0
>     UserID        = scatex
>
>     /usr/local/etc/odbcinst.ini:
>
>     [ORACLE_ODBC_Driver_Linux_ora10g]
>     Description        = Oracle 10g R2 ODBC Driver for Linux
>     Driver        = /home/oracle/oraHome1/lib/libsqora.so.10.1
>     Driver64        =
>     Setup        =
>     Setup64        =
>     UsageCount        = 1
>     CPTimeout        =
>     CPReuse        =
>
>     [ODBC]
>     Trace        = Yes
>     TraceFile        = /tmp/sql.log
>     ForceTrace        = Yes
>     Pooling        = Yes
>
>     When I run iusql I get:
>
>     [oracle at pjs-linux php-5.2.6]$ iusql SXDB scatex Scatex
>     +---------------------------------------+
>     | Connected!                            |
>     |                                       |
>     | sql-statement                         |
>     | help [tablename]                      |
>     | quit                                  |
>     |                                       |
>     +---------------------------------------+
>     SQL> select sysdate from dual;
>     +--------------------+
>     | SYSDATE            |
>     +--------------------+
>     | 2008-06-03 11:26:26|
>     +--------------------+
>     SQLRowCount returns -1
>     1 rows fetched
>     SQL> quit
>
>     I don't know why Apache is giving me Error 500 but if I run the
>     .cgi from command line everything works fine.
>
>     My .cgi is just doing a simple select (using SQLDriverConnect) and
>     then it disconnects.
>
>     >From apache logs I can see:
>
>     [Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62] Debug:
>     connect_odbc.c [connect_odbc] - ODBC string
>     'DSN=SXDB;UID=scatex;PWD=Scatex;', referer:
>     http://172.18.200.153/cgi-bin/get_ret.cgi
>     [Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62]
>     connection string is: DSN=SXDB;UID=scatex;PWD=Scatex;, referer:
>     http://172.18.200.153/cgi-bin/get_ret.cgi
>     [Tue Jun 03 11:21:20 2008] [error] [client 172.18.200.62]
>     Premature end of script headers: lista_alarmes.cgi, referer:
>     http://172.18.200.153/cgi-bin/get_ret.cgi
>
>     I can only think that Apache doesn't know how to execute
>     SQLDriverConnect. But if this is true,how do I make it work?
>
>     Any help would be very appreciated. I have no more clues or ideas
>     to solve this right now...
>
>     Best regards,
>
>     Miguel Rentes
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20080603/1b2d78f9/attachment.html>


More information about the unixODBC-support mailing list