Please post the code that uses OCILogon directly.

    One more question: Which user and group did you set for apache in httpd.conf ?

    Thomas

      Ok, here is the code:

      <?
      $db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xx.xxx.xx)(PORT = 1521)))(CONNECT_DATA=(SID=TFMA)))";
      
      $c1 = ocilogon("username","password",$db);
      ?>
      
      

      And in httpd.conf I am using apache for User and Group.

      Jim

        Did you already try this ?

        <?
        $c1 = ocilogon("username","password","TFMA");
        ?> 
        

        or (ADOD😎

        ...
        $db->Connect("TFMA", "username", "password"); 
        ....
        

        Create a phpinfo() script, save the output with your browser and post the file (rename it to .txt).

        Thomas

        Thomas

          Ok,

          Here is the error I get with that code.

          Warning: ocilogon() [function.ocilogon]: _oci_open_server: Error while trying to retrieve text for error ORA-12154 in /usr/local/apache2/htdocs/tfma/test2.php on line 2

          And attached is the phpinfo.

          Thomas: Again thank you so much for your help. Hopefully we can figure this one out.

          Jim

            Thomas,

            Any ideas since the last information I sent?

            Thanks!

            Jim

              I oversaw your last post with the attachment ... my "subscribed threads" list is very long.

              NLS_LANG is set to english. As a first step I'd suggest to change it to e.g.

              NLS_LANG=AMERICAN_AMERICA.WE8IS8859P1

              I think it's important to have at least a state where you get correct error messages instead of the "error while trying to retrieve".

              The NLS_LANG setting must match the one on the server (instance).

              Restart the web server after you modified NLS_LANG.

              Thomas

                Thomas,

                I know you are busy, you are an awesome contributor and I thank you immensely for it.

                I change the NLS_LANG and it now reflects that in the phpinfo, however I still get the exact same error.

                Let me ask you this. What ENV Vars should be set on the windows Oracle server?

                Jim

                  Sorry,

                  there was a typo in the variable value:

                  Replace
                  AMERICAN_AMERICA.WE8IS8859P1
                  with
                  AMERICAN_AMERICA.WE8ISO8859P1

                  and restart the web server.

                  EDIT:

                  The environment variables on the Windows server should be fine. The environment variables on the Linux server itself should be sufficient if you can sqlplus to the server.

                  So let's check some things with a PHP script:

                  [PHP
                  echo getenv("ORACLE_HOME");
                  if (is_file("/home/oracle/product/9.0.1/network/admin/tnsnames.ora")) {
                  echo "tnsnames.ora found";
                  } else {
                  echo "tnsnames.ora not found";
                  }
                  [/code]

                  Additionally, check which libraries PHP has been linked against on the shell:

                  ldd /full/path/to/libphp5.so

                  EDIT: Did you add the oracle lib directory to ld.so.conf and execute ldconfig ?

                  EDIT2: I read somewhere that on RedHat 8 you can have problems with the web server's user (www or whatever).

                  Two things to try: Either add the www user to the oracle (or oinstall) group (/etc/group) or change the apache user in httpd.conf to the oracle user (and maybe group). Then restart the server.
                  I'd prefer if the first one works. The second one is some kind of "ugly".

                  Thomas

                    Yes,

                    I added the Oracle Lib (/home/oracle/product/9.0.1/lib) to the conf file and executed ldconfig.

                    When I did an ldd on the so I got:

                       /home/oracle/product/9.0.1/lib/libclntsh.so.9.0 => /home/oracle/product/9.0.1/lib/libclntsh.so.9.0 (0x4035a000)
                        libcrypt.so.1 => /lib/libcrypt.so.1 (0x40d2b000)
                        libmhash.so.2 => /usr/local/lib/libmhash.so.2 (0x40d58000)
                        libgdbm.so.2 => /usr/lib/libgdbm.so.2 (0x40d94000)
                        libz.so.1 => /usr/lib/libz.so.1 (0x40d9b000)
                        libssl.so.0.9.7 => /usr/local/ssl/lib/libssl.so.0.9.7 (0x40da9000)
                        libcrypto.so.0.9.7 => /usr/local/ssl/lib/libcrypto.so.0.9.7 (0x40dd9000)
                        libresolv.so.2 => /lib/libresolv.so.2 (0x40ecd000)
                        libm.so.6 => /lib/libm.so.6 (0x40ede000)
                        libdl.so.2 => /lib/libdl.so.2 (0x40eff000)
                        libnsl.so.1 => /lib/libnsl.so.1 (0x40f02000)
                        libc.so.6 => /lib/libc.so.6 (0x40f16000)
                        libwtc9.so => /home/oracle/product/9.0.1/lib/libwtc9.so (0x41041000)
                        libpthread.so.0 => /lib/libpthread.so.0 (0x41044000)
                        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

                    Also, The script said tnsnames.ora not found, but if I copy and paste that path into my shell it opens fine and the file is there.

                    I tried adding apache to the group with no luck.

                    Jim

                      Ok,

                      you might need to chmod one of the directories.
                      Which file access permissions does /home/oracle (and maybe it's subdirectories) have ? Something like 0700 ? You might need to chmod -R a+r the oracle home directory so that the web server can access the files.

                      Thomas

                        Thomas,

                        No go.

                        I copied the tnsnames.ora to /tmp and then it found it.

                        This is quite frustrating.

                        Jim

                          Which are the oracle user and groups ? Did you try to change the apache user in httpd.conf to that user and one of the groups (just to test if that changes anything) ?

                          Thomas

                          P.S.: in the output of the phpinfo script I saw the configure option --enable-discart-path which should be --enable-discard-path (but that shouldn't cause that specific oracle problem)

                            WOW......that was it. I put in the oracle username and password and it works fine. So, it just couldn't access the tnsnames.ora file.

                            Wow...in your opinion, should I leave it like this, or other thoughts on how to get apache to read that file?

                            Thank you so so so much.

                            Jim

                              Ok,

                              that's not the best solution but at least one that works 🙂

                              Next question:

                              how does the web user look like in /etc/passwd ? Does it have a shell and a home directory ?

                              Another thing I'd try is to change the web user so that it has the group oinstall as primary group.

                              How do your /etc/passwd and /etc/group files look like. Post the parts that have to do with the web user/group and the oracle user/group.

                              Thomas

                                Ok:

                                /etc/passwd

                                apache❌48:48:Apache:/usr/local/apache2:/sbin/nologin
                                oracle❌504:502::/home/oracle/product/9.0.1:/bin/bash

                                /etd/group

                                apache❌48:oinstall,dba,developers
                                oinstall❌502:apache,oracle
                                dba❌503:oracle,apache

                                There you go.

                                Jim

                                  Two things to test:

                                  In /etc/passwd change the second 48 to 502

                                  and/or

                                  change the shell of the apache user from /sbin/nologin to /bin/bash (but that might be a security flaw).

                                  Then restart the web server (after resetting the user and group to apache and oinstall in httpd.conf) and check if it works.

                                  Besides that try to set the user to apache and the group to oinstall in httpd.conf without modifying /etc/passwd.

                                  Thomas

                                    Changing the group worked great! Such a simple fix, wow.

                                    Thank you so much for your help I really, really appreciate it!

                                    You rock!

                                    Jim

                                      Write a Reply...