I'm trying to enable extenion oci8
I uncommented its line in php.ini and added the required files for it ( oracle instant client).
Now from CMD, when I type: php --ri oci8, it shows :
oci8
OCI8 Support => enabled OCI8 DTrace Support => disabled OCI8 Version
=> 2.1.8 Revision => $Id: 4543974aab26d8a3d85257ab18d0dca4503ff9e7 $ Oracle Run-time Client Library Version => 12.1.0.2.0 Oracle
Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value oci8.max_persistent => -1 =>
-1 oci8.persistent_timeout => -1 => -1 oci8.ping_interval => 60 => 60 oci8.privileged_connect => Off => Off oci8.statement_cache_size => 20
=> 20 oci8.default_prefetch => 100 => 100 oci8.old_oci_close_semantics => Off => Off oci8.connection_class => no value => no value oci8.events => Off => Off
Statistics => Active Persistent Connections => 0 Active Connections =>
0
So it should working fine.
But when I try to connect to oracle from php I get error :
Call to undefined function Yajra\Pdo\oci_connect()
I opened to PHPINFO page, searched for oci8, the block that must be present to show it's enabled is not present.
What may be the problem?
I'm using xampp 7.2 on windows 10
Solved.
It was that my PC required restart not just Apache for PHP web to load the new enviroment variables, which is important in locating oracle instant client, which is needed by the PHP extension OCI8.
The strange thing is that PHP CLI loaded the new enviroment variables, but the PHP web didn't load it although Apache is restarted.
I noticed that from PHPinfo page, which displays the loaded envirmonment variables showing the old ones before adding oracle.
So just restated my PC and everything is now OK.
Thanks for your advice.
You must edit the php.ini file which is shown in phpinfo ("Loaded Configuration File ") option and apache restart is also required for it to work.
Related
I followed the steps to download oracle instant client and add it to PATH, add php extensions and enable it in php.ini. The basic information listed as follows:
OS: Windows 10 Enterprise x64
PHP: 7.3.30 (cli) (built: Aug 25 2021 09:48:17) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Oracle instant client: instantclient-basic-windows.x64-12.1.0.2.0
php extension for oracle database: php_oci8-2.2.0-7.3-ts-vc15-x64
After all configuration done, I test the oracle connection with following code:
$conn = oci_connect("testuser", "testpassword", "testtns;
if (!$conn) {
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else {
print "Connected to Oracle!";
}
// Close the Oracle connection
oci_close($conn);
The web page shows positive result: Connected to Oracle!
Then the problem comes: When I run the same code in command line environment, it shows:
<warning>PHP Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries in Psy Shell code on line 1</warning>
Here is some PHP configruation info:
$ php --ri oci8
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.2.0
Oracle Run-time Client Library Version => 0.0.0.0.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off
Statistics =>
Active Persistent Connections => 0
Active Connections => 0
One obvious deviation is "Oracle Run-time Client Library Version => 0.0.0.0.0"
I tried the suggestion searched from google:
copy all contents of instantclient to Apache/bin directory and remove instantclient directory from PATH
But, it doesnot work.
This problem costs me almost 2 days time, but still not solved.
Make sure the path to Oracle Instant Client libraries is specified in the PATH environment variable.
If you're not sure try run where oci.dll from a command line. If it could not find the file, then it is not in the PATH.
I am getting this error when I start my xampp server.
C:\xampp\php\ext\php_oci8.dll' - %1 is not a valid Win32 application.
I downloaded php_oci8-2.0.8-5.6-ts-vc11-x86 and extracted php_oci8.dll into C:\xampp\php\ext directory.
Also, I downloaded instantclient-basic-nt-12.1.0.2.0 (32 bit version) and added the same to the PATH variable of windows.
C:\OracleBasicClient\instantclient-basic-nt-12.1.0.2.0\instantclient_12_1 added to PATH
Still, I'm getting this error and not sure why it is coming.
My windows is 64 bit.
PHP info (xampp)
System Windows NT 6.1 (Windows 7 Professional) i586
Compiler MSVC11 (Visual C++ 2012)
Architecture x86
Thread Safety enabled
What am I possibly doing wrong and how can I fix it?
Your error shows a built-type mismatch.
Resolve it by following these steps:
Make sure you download and install oracle instantclient at: http://www.oracle.com/technetwork/topics/winsoft-085727.html, but note:
Take note of your Oracle database version; use Version 12.1.x for Oracle database 12c and Version 11.1.x for 11g releases.
In either case, make sure you download the Basic Lite version of the Oracle instantclient.
After that, do add location of your Oracle instantclient to your System variable Path under your Environment Variables. Do equally ensure that you have both the PHP of your xampp and its ext available and set there as well (if not, do add them).
Then, proceed to add a new System variable with TNS_ADMIN as variable name and the location to Oracle instantclient as variable value.
Also, define your User variables PATH with the same the location to Oracle instantclient as value.
After this stage, restart your computer for a full propagation of the newly defined environment variables.
Once on, you may open your Windows Command Prompt and run where oci* to ensure that you had your environment variables well defined; the response should look like this:
C:\Users\flex>where oci*
C:\oraclexe\app\oracle\product\11.2.0\server\bin\oci.dll
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ocijdbc11.dll
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ocijdbc11.sym
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ociw32.dll
C:\instantclient_11_2\oci.dll
C:\instantclient_11_2\oci.sym
C:\instantclient_11_2\ocijdbc11.dll
C:\instantclient_11_2\ocijdbc11.sym
C:\instantclient_11_2\ociw32.dll
C:\instantclient_11_2\ociw32.sym
If not, your must have missed something and need to revisit the process, ensuring to completing it effectively.
You may now proceed to your php.ini file (provided environment variables are well defined) and enable your oci extensions (php_oci8.dll and php_oci8_11g.dll) by uncommenting them; you can achieve that by simply removing the semi column (;) before the said extensions.
Do remember to save your php.ini file, then, restart or start your apache if it isn't already running.
To check your PHP oci8 configurations are enabled, you may go back to your Windows Command Prompt and run: php --ri oci8; the response should be similar to the one below:
C:\Users\flex>php --ri oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.1
Revision => $Id: 86f22a208f89dcd5b305e82929a7429683968b11 $
Oracle Run-time Client Library Version => 11.2.0.4.0
Oracle Compile-time Instant Client Version => 10.2
Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.events => Off => Off
Statistics =>
Active Persistent Connections => 0
Active Connections => 0
Alternatively, you can create a PHP file with <?php phpinfo(); ?> as content, then open it in your browser and search for oci8 occurrences; it should show enabled there as well.
It seems that you downloaded the DLL for a different architecture and pointed to it in your php.ini, instead of using the bundled DLL and simply un-commenting the default entry in php.ini.
I just downloaded the same version, XAMPP 3.2.2 x86, with PHP 7.1, and it ships with the DLL file that you need, which is installed to C:\xampp\php\ext\php_oci8_12c.dll.
You appear to have done everything else correctly.
To fix the issue, ensure that the effective php.ini (by default, C:\xampp\php\php.ini) references only the default file (remove the erroneous entry you added for php_oci8.dll), like so:
extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
Restart Apache and the problem should be resolved.
I try to set up connection with oracle database, but I still can't even set up the module. I have rhel 7. 2 server, and I followed whole tutorial for setting up oracle instantclient and configured it with php. One thing I completely don't understand is that oci8 module displays after php -i execution:
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.3
Revision => $Id: 59f993160cf983dd24bb391b68a65a17303d2dba $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
But there is no such module in phpinfo() inside the script. How to fix it?
PHP Version 7.0.13
Server Apache (httpd)
LD library path:
[![enter image description here][2]][2]
The common problem would be that LD_LIBRARY_PATH isn't set for Apache.
Try adding it to /etc/sysconfig/httpd like:
LD_LIBRARY_PATH=/full/path/to/oracle-client
If I have my versions right, this version of Apache (i) doesn't like the export keyword for setting variables (ii) requires a full path since it won't expand environment variables. If I'm wrong, try either or both of those.
There is a lot of information about setting the environment in the free Underground Oracle & PHP Manual, see, for example 'Setting Oracle Environment Variables for Apache' on p 108
You say you followed 'whole tutorial'. There are many tutorials. I'd recommend Oracle's installation instructions.
The answer is:
setsebool -P allow_execstack 1
You also can enable executable stack for only oci8.so with:
execstack -c /usr/lib64/php/modules/oci8.so
https://serverfault.com/questions/314336/centos-6-php-can-not-load-gdchart-so-and-oci8-so-compiled-by-me
make sure that the oci8.so is in the php extension folder
in centos is /usr/lib64/php/modules
in ubuntu xammp is /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
cd <extension folder >
sudo chmod 755 oci8.so
It works for me after
ps ax | grep "fpm"
check the pid of "php-fpm: master process"
sudo kill -9 <pid>
start php-fpm again
sudo service php-fpm start
inspired by https://stackoverflow.com/a/21693610/2538630
I am getting this error when I start my xampp server.
C:\xampp\php\ext\php_oci8.dll' - %1 is not a valid Win32 application.
I downloaded php_oci8-2.0.8-5.6-ts-vc11-x86 and extracted php_oci8.dll into C:\xampp\php\ext directory.
Also, I downloaded instantclient-basic-nt-12.1.0.2.0 (32 bit version) and added the same to the PATH variable of windows.
C:\OracleBasicClient\instantclient-basic-nt-12.1.0.2.0\instantclient_12_1 added to PATH
Still, I'm getting this error and not sure why it is coming.
My windows is 64 bit.
PHP info (xampp)
System Windows NT 6.1 (Windows 7 Professional) i586
Compiler MSVC11 (Visual C++ 2012)
Architecture x86
Thread Safety enabled
What am I possibly doing wrong and how can I fix it?
Your error shows a built-type mismatch.
Resolve it by following these steps:
Make sure you download and install oracle instantclient at: http://www.oracle.com/technetwork/topics/winsoft-085727.html, but note:
Take note of your Oracle database version; use Version 12.1.x for Oracle database 12c and Version 11.1.x for 11g releases.
In either case, make sure you download the Basic Lite version of the Oracle instantclient.
After that, do add location of your Oracle instantclient to your System variable Path under your Environment Variables. Do equally ensure that you have both the PHP of your xampp and its ext available and set there as well (if not, do add them).
Then, proceed to add a new System variable with TNS_ADMIN as variable name and the location to Oracle instantclient as variable value.
Also, define your User variables PATH with the same the location to Oracle instantclient as value.
After this stage, restart your computer for a full propagation of the newly defined environment variables.
Once on, you may open your Windows Command Prompt and run where oci* to ensure that you had your environment variables well defined; the response should look like this:
C:\Users\flex>where oci*
C:\oraclexe\app\oracle\product\11.2.0\server\bin\oci.dll
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ocijdbc11.dll
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ocijdbc11.sym
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ociw32.dll
C:\instantclient_11_2\oci.dll
C:\instantclient_11_2\oci.sym
C:\instantclient_11_2\ocijdbc11.dll
C:\instantclient_11_2\ocijdbc11.sym
C:\instantclient_11_2\ociw32.dll
C:\instantclient_11_2\ociw32.sym
If not, your must have missed something and need to revisit the process, ensuring to completing it effectively.
You may now proceed to your php.ini file (provided environment variables are well defined) and enable your oci extensions (php_oci8.dll and php_oci8_11g.dll) by uncommenting them; you can achieve that by simply removing the semi column (;) before the said extensions.
Do remember to save your php.ini file, then, restart or start your apache if it isn't already running.
To check your PHP oci8 configurations are enabled, you may go back to your Windows Command Prompt and run: php --ri oci8; the response should be similar to the one below:
C:\Users\flex>php --ri oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.1
Revision => $Id: 86f22a208f89dcd5b305e82929a7429683968b11 $
Oracle Run-time Client Library Version => 11.2.0.4.0
Oracle Compile-time Instant Client Version => 10.2
Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.events => Off => Off
Statistics =>
Active Persistent Connections => 0
Active Connections => 0
Alternatively, you can create a PHP file with <?php phpinfo(); ?> as content, then open it in your browser and search for oci8 occurrences; it should show enabled there as well.
It seems that you downloaded the DLL for a different architecture and pointed to it in your php.ini, instead of using the bundled DLL and simply un-commenting the default entry in php.ini.
I just downloaded the same version, XAMPP 3.2.2 x86, with PHP 7.1, and it ships with the DLL file that you need, which is installed to C:\xampp\php\ext\php_oci8_12c.dll.
You appear to have done everything else correctly.
To fix the issue, ensure that the effective php.ini (by default, C:\xampp\php\php.ini) references only the default file (remove the erroneous entry you added for php_oci8.dll), like so:
extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
Restart Apache and the problem should be resolved.
Ive installed httpd and httpd-devel packages and installed php and php-devel on a server. I downloaded and installed the basic client and sdk for oracle and then proceeded to use PECL to install OCI8 extension.
When I try running the oci_connect function page on CLI, It works fine. But when I try to load the same php page over http, i get the following error:
Fatal error: Call to undefined function oci_connect() in /var/www/html/index.php on line 10
I have compared the php ini from both and notice that /etc/php.d/oci8.ini file is loaded in the cli and the http version
however, the module details are only available on the cli version:
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.0.8
Revision => $Id: f04114d4d67cffea4cdc2ed3b7f0229c2caa5016 $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
I cant for the life of me figure out why only one loads the extension properly when they both have the same configuration file.
Thanks for any help!
I managed to fix this by disabling SELINUX