note 35119 modified in function.ocilogon by sixd
| From: | sixd@php.net | Date: | Mon, 05 Oct 2009 01:32:02 +0000 |
| Subject: | note 35119 modified in function.ocilogon by sixd | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161289@lists.php.net to get a copy of this message | ||
For those having Oracle errors, I find out that little something, while using Apache2. I don't
know if this applies also to Apache 1.x, but for Apache2, this is the ultimate solution!
Especially with ORA-12154 and ORA-12505, some said to write the following code in your php script,
but if you have access to the configuration or your web server, DON'T!
<?php
putenv("ORACLE_SID=TESTDB");
//putenv("ORACLE_HOME=/oracle/ora90");
//putenv("TNS_ADMIN=/oracle/ora90/network/admin");
$username = "scott";
$passwd = "tiger";
$db="(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=yourTargetMachine)(PORT=1521)
)
)
(CONNECT_DATA=(SERVICE_NAME=TESTDB))
)";
$conn = OCILogon($username,$passwd,$db);
...
?>
All right, like I said, if you have access to the configuration of apache, there is a file in
$APACHE2/bin called envvars. Simply put the necessary environment variables needed by Oracle in this
file: ORACLE_SID, ORACLE_BASE, ORACLE_HOME and myself I also added LD_LIBRARY_PATH with oracle
directories.
At first, my problem was that I didn't had all the environment sets when rebooting the server,
but if I'd stop apache, then restart it, while beeing root, all the environment was there.
Setting the envvars file correctly solved the reboot problem.
Hope this will help!
Franks
--was--
For those having Oracle errors, I find out that little something, while using Apache2. I don't
know if this applies also to Apache 1.x, but for Apache2, this is the ultimate solution!
Especially with ORA-12154 and ORA-12505, some said to write the following code in your php script,
but if you have access to the configuration or your web server, DON'T!
<?php
putenv("ORACLE_SID=TESTDB");
//putenv("ORACLE_HOME=/oracle/ora90");
//putenv("TNS_ADMIN=/oracle/ora90/network/admin");
$username = "scott";
$passwd = "tiger";
$db="(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=yourTargetMachine)(PORT=1521)
)
)
(CONNECT_DATA=(SERVICE_NAME=TESTDB))
)";
$conn = OCILogon($username,$passwd,$db);
...
?>
All right, like I said, if you have access to the configuration of apache, there is a file in
$APACHE2/bin called envvars. Simply put the necessary environment variables needed by Oracle in this
file: ORACLE_SID, ORACLE_BASE, ORACLE_HOME and myself I also added LD_LIBRARY_PATH with oracle
directories.
At first, my problem was that I didn't had all the environment sets when rebooting the server,
but if I'd stop apache, then restart it, while beeing root, all the environment was there.
Setting the envvars file correctly solved the reboot problem.
Hope this will help!
Franks
http://php.net/manual/en/function.ocilogon.php