Re: logon denied using OCIlogon, PHP4, Oracle 8.1.5/Linux
| From: | Joe Brown | Date: | Fri, 20 Oct 2000 07:10:19 +0000 |
| Subject: | Re: logon denied using OCIlogon, PHP4, Oracle 8.1.5/Linux | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3831@lists.php.net to get a copy of this message | ||
I found the info I needed to get this working at
http://www.php.net/manual/ref.oci8.php
There are a few environment variables that need to be set before starting
Apache.
I found it important that these variables are set _only_ when starting
apache, if you set them in the script. Specifically LD_PRELOAD caused the
stop) section to quit working.
---this is the start secition of my /etc/rc.d/init.d/httpd script ---
case "$1" in
start)
#php/oracle vars
export ORACLE_SID=ORCL
export ORACLE_HOME=/home/oracle/product/8.1.5
export NLS_LANG=american_america.us7ascii
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export LD_PRELOAD=/usr/lib/libpthread.so
PATH=$PATH:$ORACLE_HOME/bin
#end php/oracle vars
echo -n "Starting httpd: "
daemon /usr/local/www/bin/httpd
echo
touch /var/lock/subsys/httpd
;;
"Mike Hanney" <mike@tradebasics.com> wrote in message
news:4.3.2.7.1.20000719122343.00aacd20@195.200.15.228...
> Hi,
>
> I'm evaluating PHP4.0.1pl2 versus Coldfusion4.5.1 with
Apache/Oracle/Linux.
>
> Everything is going swimmingly except for one minor problem connecting to
> Oracle using PHP4's OCIlogon function. I get invalid username/password;
> logon denied. However, I can connect using this username@database/password
> with SQL*Plus, Coldfusion, Perl:DBI and even remotely using
> Access2000/Oracle ODBC driver, but not PHP4 (or 3 for that matter).
>
> My TNSNAMES.ORA and LISTENER.ORA files are for a default o8i install,
> Oracle environment variables are set for all users including www and I've
> tried adding the www user to the oracle group. Finally, I've searched the
> lists, read the manual and tried every possible combination of service
> name, database name and instance.
>
> Details follow.
>
> Any suggestions greatly appreciated.
>
> Thanks.
>
> Mike.
>
>
> ------------------------------------------------------------------------
> My test script:
>
> <?
>
> $conn = ocilogon( "username@oracle-linux", "passwd",
> "oracle-linux") or
die;
> $stmt = ocipars($conn, "SELECT * FROM STAFF_TBL") or die;
>
> ociexecute($stmt);
>
> echo "<HTML><PRE>\n";
>
> while (ocifetch($stmt)) {
> print "\n";
> $ncols = ocinumcols($stmt);
> for ( $i = 1; $i <= $ncols; $i++ ) {
> $column_name = ocicolumnname($stmt,$i);
> $column_value = ociresult($stmt,$i);
> print $column_name . ': ' . $column_value . "\n";
> }
> print "\n";
> }
> ocifreestatement($stmt);
> ocilogoff($conn);
>
> echo "</PRE></HTML>\n";
>
> ocilogoff($handle);
>
> ?>
>
> The Errors:
> ----------
> Warning: OCISessionBegin: ORA-01017: invalid username/password; logon
> denied in oracle_test.php3 on line 3
>
> I get the same error when I ommit the optional 3rd parameter (apparently
> using ORACLE_SID=v8i815 from the environment variables).
>
> using...
> $conn = ocilogon( "username", "passwd", "oracle-linux") or die;
> I get...
>
> Warning: OCISessionBegin: ORA-12705: invalid or unknown NLS parameter
value
> specified in oracle_test.php3 on line 3
>
> and finally using...
> $conn = ocilogon( "username", "passwd", "myservicename") or die;
> I get...
>
> Warning: _oci_open_server: ORA-12154: TNS:could not resolve service name
in
> oracle_test.php3 on line 3
>
>
> ------------------------------------------------------------------------
> # TNSNAMES.ORA Configuration
> File:/u01/app/oracle/product/8.1.5/network/admin/tnsnames.ora
> # Generated by Oracle Net8 Assistant
>
> oracle-linux =
> (DESCRIPTION =
> (ADDRESS_LIST =
> (ADDRESS =
> (PROTOCOL = TCP)
> (HOST = 255.255.255.255) # can't disclose actual i.p. address
here!
> (PORT = 1521)
> )
> )
>
> (CONNECT_DATA =
> (SERVICE_NAME = myservicename)
> )
> )
>
> ------------------------------------------------------------------------
>
> # LISTENER.ORA Configuration
> File:/u01/app/oracle/product/8.1.5/network/admin/listener.ora
> # Generated by Oracle Net8 Assistant
>
> LISTENER =
> (DESCRIPTION_LIST =
> (DESCRIPTION =
> (ADDRESS =
> (PROTOCOL = TCP)
> (HOST = 255.255.255.255) # can't disclose actual i.p. address
here!
> (PORT = 1521)
> )
> (PROTOCOL_STACK =
> (PRESENTATION = TTC)
> (SESSION = NS)
> )
> )
> )
>
> SID_LIST_LISTENER =
> (SID_LIST =
> (SID_DESC =
> (GLOBAL_DBNAME = myservicename) # same as SERVICE_NAME in
TNSNAMES.ORA.
> (ORACLE_HOME = /u01/app/oracle/product/8.1.5)
> (SID_NAME = v8i815)
> )
> )
>
> ------------------------------------------------------------------------
>
> Site Info:
>
> OS: Red Hat Linux 6.1, 2.2.12-20, Intel.
>
>
> HTTP server: Apache/1.3.9 (Unix) PHP/4.0.1pl2
> Loaded Modules:
> mod_php4, mod_setenvif, mod_auth_db, mod_auth_dbm, \
> mod_auth, mod_access, mod_alias, mod_userdir, \
> mod_actions, mod_imap, mod_asis, mod_cgi, \
> mod_dir, mod_autoindex, mod_include, mod_status, \
> mod_negotiation, mod_mime, mod_log_referer, \
> mod_log_agent, mod_log_config, mod_env, http_core
>
>
> PHP 4.0.1pl2 (linked as static Apache module).
> ./configure --with-apache=/usr/local/apache \
> --with-mysql=/usr/local/mysql \
> --with-GD=/usr/local/gd1.2 \
> --with-oracle=/u01/app/oracle/product/8.1.5 \
> --with-oci8=/u01/app/oracle/product/8.1.5 \
> --enable-sigchild \
> --with-wddx \
> --with-xml
>
> <? echo phpinfo() ?> says:
> oracle
> Oracle Support: enabled
> Oracle Version: 8.1
> Compile-time ORACLE_HOME: /u01/app/oracle/product/8.1.5
> Libraries Used:
>
> oci8
> OCI8 Support: enabled
> Oracle Version: 8.1
> Compile-time ORACLE_HOME: /u01/app/oracle/product/8.1.5
> Libraries Used:
>
>
> Oracle Info:
> Oracle 8.1.5.0.2
> SQL*Plus 8.1.5.0.0
> Environment Variables (set for users root and www (apache runs as www))
> ORACLE_OWNER=oracle8i
> ORACLE_SID=v8i815
> ORACLE_HOME=/u01/app/oracle/product/8.1.5
> ORACLE_BASE=/u01/app/oracle
> NLS_LANG='english_united kingdom.we8iso8859p1'
> ORA_NLS33=$ORACLE_HOME/ocommon/nls/adm
>
> Hardware:
> 300Mhz AMD K6-2, 256M Ram, 2 x 9gig IDE drives.
> ------------------------------------------------------------------------
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>