tanveer Posted June 22, 2009 Share Posted June 22, 2009 Hi all, I installed oracle client and compiled php with oracle home but still it provides me this output below: Fatal error: Call to undefined function OCILogin() in /usr/local/apache/htdocs/oratest.php on line 3 oratest.php ------------ <?php $conn = OCILogin ("",""); ?> the ORACLE_HOME variable is set also. PHP compiled option: /configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache/bin/apxs' '--with-config-file-path=/usr/local/php' '--with-gd' '--with-gdbm' '--with-mysql=/usr/local/mysql' '--with-libxml-dir=/usr/local/packages/libxml2' '--enable-force-cgi-redirect' '--disable-cgi' '--with-gettext' '--with-zlib' '--with-sqlite' '--enable-pdo' '--with-pdo-sqlite' '--with-pdo-mysql=/usr/local/mysql' '--with-png-dir=/usr/local/packages/libpng' '--with-oci8=/opt/oracle/product/client' Any help. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/ Share on other sites More sharing options...
gizmola Posted June 22, 2009 Share Posted June 22, 2009 When you look at the phpinfo() does it have a section for Oracle? I'm guessing not. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-861107 Share on other sites More sharing options...
tanveer Posted June 22, 2009 Author Share Posted June 22, 2009 Yes, it does have. I compiled it with both oracle and mysql. oci8 OCI8 Support enabled Version 1.2.5 Revision $Revision: 1.269.2.16.2.43 $ Active Persistent Connections 0 Active Connections 0 Oracle Version 10.1 Compile-time ORACLE_HOME /opt/oracle/product/client Libraries Used no value Temporary Lob support enabled Collections support enabled Directive Local Value Master Value oci8.default_prefetch 10 10 oci8.max_persistent -1 -1 oci8.old_oci_close_semantics 0 0 oci8.persistent_timeout -1 -1 oci8.ping_interval 60 60 oci8.privileged_connect Off Off oci8.statement_cache_size 20 20 Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-861114 Share on other sites More sharing options...
tanveer Posted June 22, 2009 Author Share Posted June 22, 2009 It shows this message Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /usr/local/apache/htdocs/oratest.php on line 2 Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-861115 Share on other sites More sharing options...
gizmola Posted June 22, 2009 Share Posted June 22, 2009 Ok, is the user running apache a member of the oracle group? Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-861121 Share on other sites More sharing options...
tanveer Posted June 22, 2009 Author Share Posted June 22, 2009 [root@localhost ~]# groups daemon daemon : daemon bin adm lp [root@localhost ~]# groups oracle oracle : oinstall dba So it means daemon user who is running apache is not a member of oracle group. Should I make him? Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-861130 Share on other sites More sharing options...
tanveer Posted June 22, 2009 Author Share Posted June 22, 2009 One more thing. If I run it from shell then it gives me this message Warning: ocilogon(): ORA-12162: TNS:net service name is incorrectly specified in /usr/local/apache/htdocs/oratest.php on line 2 The code is: <?php $conn=OCILogon("",""); ?> Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-861138 Share on other sites More sharing options...
gizmola Posted June 22, 2009 Share Posted June 22, 2009 Yeah, as far as I know it continues to be an issue that you need to have the apache process be in the same group as the oracle user. The instant client lets you get around that. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-861420 Share on other sites More sharing options...
tanveer Posted June 23, 2009 Author Share Posted June 23, 2009 Ok I am confused. The oracle team of ours installed the client and my part was to compile apache,php with mysql and oracle support which I did as my post. Now what is instant client and how to use that to connect to oracle server? Whats the prob with the below fucntion in code? I also made daemon user a member of group oinstall but still doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-861619 Share on other sites More sharing options...
gizmola Posted June 23, 2009 Share Posted June 23, 2009 tanveer, Here's something you should probably know about Oracle if you don't already, and that is that you can make an account on the Oracle Technology Network (OTN) which will give you access to oracle software, forums and information. The Oracle instant client for linux basically is a package that makes it much easier than it was previously to get the Oracle client libraries installed. If the admins already installed the oracle client the traditional way, using the oracle universal installer, then you need to have the apache process in the oracle group so that it can see the files it will need to do the client networking. As for your error, I'm not sure what it is. Please paste in the exact code you're using. You can of course block out any passwords and ip's or domain names with *** but I am not sure what your test code is doing. In your example above you were calling ocilogon with no connect string, so of course that won't work. I'm assuming here, that you actually have something different, but you've not pasted the code. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-862248 Share on other sites More sharing options...
tanveer Posted June 24, 2009 Author Share Posted June 24, 2009 Hello, Thanks for your replies. I already set the apache user under oracle group. [root@localhost ~]# groups daemon daemon : daemon bin adm lp oinstall [root@localhost ~]# groups oracle oracle : oinstall dba Oracle users .bash_profile sample export ORACLE_BASE=/opt/oracle export ORACLE_HOME=/opt/oracle/product/client export LD_LIBRARY_PATH=$ORACLE_HOME/lib alias cls='clear' PATH=$PATH:$ORACLE_HOME/bin export PATH Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-862436 Share on other sites More sharing options...
gizmola Posted June 24, 2009 Share Posted June 24, 2009 Well that looks fine then, of course you need to restart apache after a change like that with: service httpd restart Any luck since then? If not, will need to see your code to offer any further help. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-862932 Share on other sites More sharing options...
tanveer Posted June 25, 2009 Author Share Posted June 25, 2009 Yes, I restarted the service but still same. From browser it gives message like: Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /usr/local/apache/htdocs/oratest.php on line 7 And if run from shell then it gives this: Warning: ocilogon(): ORA-12154: TNS:could not resolve the connect identifier specified in /usr/local/apache/htdocs/oratest.php on line 7 Now what is this TNS and does this means anything needs to be done like database settings in some oracle files? Further I can't download the instant client as its giving me errors every time. One more thing, what the diff between OCILogon and oci_pconnect? Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-863244 Share on other sites More sharing options...
tanveer Posted June 25, 2009 Author Share Posted June 25, 2009 And my test code: <?php $user="user"; $password="passwd"; $conn =OCILogon($user, $password, "10.10.xx.xx/testms"); if ($conn) { echo "Success"; }else{ $e = oci_error(); echo $e; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-863246 Share on other sites More sharing options...
gizmola Posted June 25, 2009 Share Posted June 25, 2009 Ok, so the problem is that oracle has it's own networking protocol and naming system called TNS. Typically you set up entries for this in the TNSNAMES.ORA file. It's a kind of arcane LISP like syntax. Once you have a valid TNSNAMES entry for the server you're trying to attach to, you can try to use the simplified connect string you're attempting to utilize, but the problem looks to me like there's no such entry. You can try to feed the entry to it in the connect string parameter. You must know the SID of the server, which it looks like you did ('testms'). You can try this: $db = " (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.10.XXX.XXX) // your serverIP (PORT = 1521) ) (CONNECT_DATA =(SID = testms)) )"; $conn = OCILogon($user, $password, $db) or die (ocierror()); In regards to ociLogon vs. pconnect, pconnect makes a persistent connection. Unlike mysql, the oracle login process is very heavy, and can take a long time. To get decent performance out of oracle, you need to use persistent connections. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-863622 Share on other sites More sharing options...
tanveer Posted June 30, 2009 Author Share Posted June 30, 2009 HI, I used your code and now its showing no warnings or error in browser. But in apache log I am getting this: [Tue Jun 30 18:06:06 2009] [error] [client 10.10.x.xx] PHP Warning: ocilogon() [<a href='function.ocilogon'>function.ocilogon</a>]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /usr/local/apache/htdocs/test.php on line 13 Code: <?php $db = " (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.10.xx.xx) // your serverIP (PORT = 1521) ) (CONNECT_DATA =(SID = PRODQC)) )"; $conn = OCILogon("user", "password", $db) or die (ocierror()); What is difference between SID and SERVICE_NAME in CONNECT_DATE section? Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-866272 Share on other sites More sharing options...
gizmola Posted June 30, 2009 Share Posted June 30, 2009 tanveer: Please make a script with this in it and report back the findings: echo "ORACLE_HOME=".getenv("ORACLE_HOME"); Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-866621 Share on other sites More sharing options...
tanveer Posted July 1, 2009 Author Share Posted July 1, 2009 It displays nothing. It doesn't even echo the word 'ORACLE_HOME=' Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-866840 Share on other sites More sharing options...
gizmola Posted July 1, 2009 Share Posted July 1, 2009 It displays nothing. It doesn't even echo the word 'ORACLE_HOME=' You must have a syntax error. It will display something when it works properly. Check your apache error log to see what the issue is. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-866923 Share on other sites More sharing options...
tanveer Posted July 6, 2009 Author Share Posted July 6, 2009 Thanks a lot for all the support. Its solved now. What I did was first set the ORACLE_HOME environment variable and then recompile the PHP again with that ORACLE_HOME and set the ORACLE_HOME variable in /etc/profile for all users. The DBA team did some tweaking on tnsnames.ora and it started working. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-869637 Share on other sites More sharing options...
gizmola Posted July 8, 2009 Share Posted July 8, 2009 No worries, glad you got it working. You might mention to them for any future machines that the instant client is a better way to go for machines that will connect to an instance running on another machine. Quote Link to comment https://forums.phpfreaks.com/topic/163203-connect-to-oracle-server-with-oracle-client-in-redhat/#findComment-870803 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.