0

I have a redhat server with httpd and oci8 installed properly. I can access correctly oracle functions like oci_connect() when using a script runs through the browser. This is my problem: I have a shell script shell.sh that has the content:

shell.sh:
/php/bin/path script.php

and in script.php I have the code:

script.php
$conn = oci_connect('user', 'pass', 'MYDB');

I am having the error Uncaught Error: Call to undefined function oci_connect(). I tried to log phpinfo() inside the script.php and I see that oci8 is not loaded! How can I load it?

This is what I tried:

shell.sh

/php/bin/path -c "/path/to/php.ini" script.php

and inside php.ini I added :

php.ini
extension=oci8.so

When running only script.php throught the browser for exemple everything connect correctly and phpinfo has all extensions activated.

Anyone encountered this issue? Thanks

2 Answers 2

1

What does the following command show you?

php --ini | grep Loaded
Loaded Configuration File:         /etc/php/8.2/cli/php.ini

in my case there is an extra php.ini for the CLI

1
  • I get /etc/opt/php-7.4/php.ini using php_ini_loaded_file() function in script.php. That path is the same used when running the script through browser. I just found out that the oracle instant client was installed without using "--with-oci8=shared" option so I am wondering if that is why php is not loading it directly. However since the same php.ini is used I expect it to find my so file..strange
    – el sparrow
    Commented Jan 22 at 20:18
1

The issue was the php.ini file and oracle instant client library files did not have the good permissions. Once I added the correct permission, everything worked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.