Verification: a143cc29221c9be0

Php and oracle instant client

Table of Contents

  • About PHP for Oracle Linux
  • Available PHP Releases
  • Installation
  • Set up Required Repositories
  • Installing PHP
  • Updating PHP
  • Connecting PHP to Oracle Database with the php-oci8 Extension
  • About Oracle Instant Client
  • Installing php-oci8
  • Installing PHP on Oracle Linux 8 via AppStream Modules
  • PHP in Containers
  • Getting Help

About PHP for Oracle Linux

The PHP repositories contain the latest builds of stable PHP releases from the community, including the oci8 extension for the Oracle Database. They are provided without support.

Available PHP Releases


These are the steps to install PHP.

Set up Required Repositories

To configure the yum repositories shown above on your system, install the repository setup packageoracle-php-release-el7. After installing this package, the default enabled repository is that for the latest available PHP release. To install the repository setup package for Oracle Linux 7:

$ sudo yum install -y oracle-php-release-el7

Installing PHP

Then, to install the latest available release of PHP on Oracle Linux 7:

$ sudo yum install -y php

Updating PHP

If you have PHP already installed, and a newer release has been published, make sure you update oracle-php-release-el7 first.

$ sudo yum update oracle-php-release-el7
$ sudo yum update php

Connecting PHP to Oracle Database with the PHP OCI8 Extension

The PHP OCI8 database extention enables access to Oracle Database with support for SQL, PL/SQL, bind variables, large object (LOB) types as well connection pooling and result caching features of Oracle Database. Read this blog post for a complete example connecting a PHP 7.4 application to Oracle Database.

Installing PHP OCI8

Each PHP release has its own repository on Oracle Linux yum server and each of those repositories also contains a corresponding RPM for the OCI8 extension, built for a specific major release of Oracle Instant Client. These RPMs follow this naming scheme: php-oci8. For example, on Oracle Linux 7, the PHP OCI8 RPM for PHP 7.4 is built with Instant Client 19c and is named: php-oci8-19c. To install it:

$ sudo yum install php-oci8-19c

About Oracle Instant Client

PHP OCI8 depends on Oracle Instant Client. Yum configurations for Oracle Instant Client are delivered via the oracle-release-el7 and oracle-release-el6 packages

Installing Oracle Instant Client

To install Oracle Instant Client on Oracle Linux 7:

$ sudo yum -y install oracle-release-el7
$ sudo yum -y install oracle-instantclient19.5-basic

As of Oracle Instant Client 19c, no additional configuration is needed for applications to use the Oracle client.

Installing PHP on Oracle Linux 8 via AppStream Modules

Oracle Linux 8 introduces the concept of Application Streams, where multiple versions of user-space components can be delivered and updated more frequently than the core operating system packages in RPM format or groups of related RPMs called Modules. Oracle Linux 8 offers several independently updated versions of PHP via Module Streams. For mode details, please refer to the documentation.

To list available Module Streams for PHP:

$ dnf module list php

To install PHP 7.4 :

$ sudo dnf install @php:7.4

PHP in Containers

On GitHub we provide resources to build your own container images or pull pre-built images, including:

  • PHP Command Line Interface tool (PHP CLI)
  • PHP via FastCGI Process Manager (FPM)
  • PHP via Apache HTTP Server with mod_php
  • Variants of each of the above with Oracle Database connectivity via PHP-OCI8

See the reference below to developer and run PHP applications in containers:

  • Example Dockerfiles for PHP: Oracle Linux 8, Oracle Linux 7
  • PHP container images on GitHub Container registry: Oracle Linux 8, Oracle Linux 7

Install Instant Client on Linux

Download the instant client zip file or RPM from the OTN Instant Client page. All installations require the Basic or Basic Light RPM.

Install instant client with RPM

  1. Install the RPMs as the root user, using yum.
    # yum install oracle-instantclient12.2-basic-
  2. Add the directory for the Instant Client to the environment variable LD_LIBRARY_PATH, for example:
    # export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client/lib:$LD_LIBRARY_PATH
  3. Add the bin directory of Instant Client to the PATH environment variable, for example:
    # export PATH=/usr/lib/oracle/12.2/client/bin:$PATH

Install Instant Client with ZIP

  1. Download the Basic or Basic Light ZIP package.
  2. Unzip the packages into a single directory such as /opt/oracle/instantclient_12_2
    # cd /opt/oracle
    # unzip
  3. Create the appropriate and links for the version of Instant Client. For example
    # ln -s
    # ln -s
  4. Install the libaio package (also called libaio1 in some distros), for example on Oracle Linux, run this as the root user:
    # yum install libaio
  5. Set the environment variable LD_LIBRARY_PATH to the directory where you unzipped the instant client, for example:
    # export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH
  6. Add the bin directory of Instant Client to the PATH environment variable, for example:
    # export PATH=/opt/oracle/instantclient_12_2:$PATH

Install PHP OCI8

You can download and install the latest version of OCI8 with PECL.

To install for PHP 7:

# pecl install oci8

To install for PHP 5.2 - PHP 5.6

# pecl install oci8-2.0.12

PECL is a repository of PHP extensions written in C and it comes along with PEAR (PHP Extensions and Application Repository). Follow the steps below to install PECL if you don't already have it.

On Linux and UNIX :

# wget
# php go-pear.phar

On Windows, you can copy the script at this location to a local file named go-pear.phar and run

c:\php> php go-pear.phar

Enable OCI8

After installation the OCI8 shared extension library will be available in the extension directory. To enable this extension, edit php.ini and add the following line.

On windows, the extension DLL file will be available in the extension directory. You need to uncomment the below line in php.ini file.


Restart Apache

THe final step in the installation is to restart your Apache webserver for the extension to load.