How do i install or enable phps oci8 extension?

The OCI8 extension lets you access Oracle Database.

Use 'pecl install oci8' to install for PHP 8.1.

Use 'pecl install oci8-3.0.1' to install for PHP 8.0.

Use 'pecl install oci8-2.2.0' to install for PHP 7.

Use 'pecl install oci8-2.0.12' to install for PHP 5.2 - PHP 5.6.

Use 'pecl install oci8-1.4.10' to install for PHP 4.3.9 - PHP 5.1.

The current OCI8 extension can be linked with Oracle Client libraries from Oracle Database 11.2 or later. (OCI8 3.0 and earlier can be linked with 10g or later). The Oracle Client libraries are in the free Oracle Instant Client from https://www.oracle.com/database/technologies/instant-client.html. They are also included in your database installation.

Oracle's standard cross-version connectivity applies. For example, PHP OCI8 linked with Oracle Client 19c can connect to Oracle Database 11.2 onward. See Oracle's note "Oracle Client / Server Interoperability Support" (ID 207303.1) for details.

install Oracle PHP Extension (oracle OCI8) - instantclient for Mac OS 10.12.6 - homebrew environnement - on PHP 7.2

Installation

This procedure is tested on Mac OS X 10.12.6

PHP 7.2 installed with Homebrew.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

  • instantclient-basic-macos.x64-12.2.0.1.0-2.zip
  • instantclient-sqlplus-macos.x64-12.2.0.1.0-2.zip
  • instantclient-sdk-macos.x64-12.2.0.1.0-2.zip

Create and unzip all theses files into a the directory /usr/local/instantclient/12.2.0.1/.

sudo ln -sfn /usr/local/instantclient/12.2.0.1/sdk/include/*.h /usr/local/include/
sudo ln -sfn /usr/local/instantclient/12.2.0.1/sqlplus /usr/local/bin/
sudo ln -sfn /usr/local/instantclient/12.2.0.1/*.dylib /usr/local/lib/
sudo ln -sfn /usr/local/instantclient/12.2.0.1/*.dylib.12.1 /usr/local/lib/
sudo ln -sfn /usr/local/lib/libclntsh.dylib.12.1 /usr/local/lib/libclntsh.dylib

Install extension with pecl

pecl install oci8

On success installation, you will have messages like the following:

Build process completed successfully
Installing '/usr/local/Cellar/php/7.2.7/pecl/20170718/oci8.so'
install ok: channel://pecl.php.net/oci8-2.1.8
Extension oci8 enabled in php.ini

If the script prompt you to provide the path to ORACLE_HOME directory, respond with:

instantclient,/usr/local/lib

And your are done, normally pecl will automatically load the extension in your php.ini. If not, add the following line to your php.ini:

Run php --ini to check your php.ini file location.

extension=oci8.so

Then do test the setup by running php -v.

If you are having error code like the following:

Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so (dlopen(/usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so, 9): image not found), /usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so.so (dlopen(/usr/local/Cellar/php/7.2.7/lib/php/20170718/oci8.so.so, 9): image not found)) in Unknown on line 0

You can copy the oci8.so generated to the target path. In above case as following:

cp /usr/local/Cellar/php/7.2.7/pecl/20170718/oci8.so /usr/local/Cellar/php/7.2.7/lib/php/20170718/

Then you should see no more error message when runninng php -v.

Restart your HTTP Server and test.

Enjoy (or try to...) !

I have specific problem with making OCI8 work on my server installation.

First setup:

  • Win 2008 Server 32bit
  • ZendServer for PHP with Apache2.2
  • PHP version 5.3.14 which was without php_oci8 files
  • No oracle things installed

I need to be able to connect to remote oracle database, so I find out, that OCI8 extension should be used. To make OCI8 work, I also should need at least Oracle Instant Client on server, because of certain DLL OCI8 need.

What I did?

  • downloaded Oracle Instant Client from their sites ( oracle download site ), version 11.2.0.4.0
  • unpacked into folder, I choosed Program Files/oci_11_2
  • added to windows variable path the address
  • restarted Win
  • downloaded php_oci8 libraries from PECL ( PECL oci8 dl site )
  • put them into the ext directory set in php.ini
  • added extension=php_oci8.dll into php.ini
  • restarted apache

After all this I checked php_info to see, if everything is ok, however no signs of oci8.

I tried older Oracle instant client, swtiching between php_oci8.dll, php_oci8_11g.dll or php_oci8_12c.dll, yet nothing helped.

I found, that due to php_info in environment section doesn't show the same values, as one that are set in windows. From php error log I also got following:

[30-May-2014 08:02:16 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\Program Files\Zend\ZendServer\lib\phpext\php_oci8_11g.dll' - The specified module could not be found. in Unknown on line 0

Currently, I have no idea what to do, unless trying reinstalling php(which I don't want to because of many problematics connected with that), different Oracle instant clients or differenct php_oci8 libraries. I google for some hours, tried looking on Stack, but no solution, just some tips, that didn't help. Have someone encountered and solved something similar?

How do I enable OCI8?

To install the OCI8 extension, we need to install some additional package on our server..
Run these command: apt-get install php-dev php-pear build-essential libaio1..
Once installed, we need to get the OCI8 file. ... .
We need to tell PHP to load the OCI8 extension. ... .
Refresh the server. ... .
Restart the PHP-FPM..

How to enable OCI8 in PHP windows?

1 Answer.
Download instantclient and place "C:\instantclient_11_2".
Set environment variable for C:\instantclient_11_2..
Check your php version i.e. PHP Version 5.6.15..
Un-Comment "extension=php_oci8_11g.dll" in php.ini and restart apache..
check php_info(), oci8 should be enabled. Thats all..

How to install OCI8 for PHP?

Oracle OCI8 PHP Installation.
Step 1: Download Oracle Instant Client Basic AND SDK Packages. ... .
Step 2: Install the Oracle Instant Client Basic and SDK Packages. ... .
Step 3: Download the OCI8 Extension from PECL. ... .
Step 4: Build the PHP OCI8 Module. ... .
Step 5: Install the OCI8 PHP Module. ... .
Step 6: Restart Apache to Load New Changes..

How enable OCI8 in PHP Linux?

Install Oracle Client Instant & SDK.
Download the latest Oracle Instant Client and SDK. Download the latest Oracle Instant Client and SDK from the Oracle website. ... .
Extract the files. ... .
Add in the ldconfig's config folder. ... .
Install packages. ... .
Install the OCI8 extension via PECL. ... .
Load extension from php.ini. ... .
Restart & check..