Installing OCI8 on RHEL


If you plan to use PHP to connect to an Oracle database, then you’ll want to install OCI8, which is a pecl extension for Oracle. You can also use PDO_OCI as mentioned in The Underground PHP and Oracle Manual, however Oracle does not contribute to PDO_OCI; if you look this up (for example on stackoverflow), you’ll find a number of users have had various problems getting PDO_OCI to work. So installing OCI8 is highly recommended!

Stop Apache

Run the following command to stop Apache:

sudo service httpd stop

Install Instant Client

Go to Oracle’s instant client download page, and select the link for you Linux architecture. You’ll have to click on the “Accept License Agreement” radio button, and you’ll have to download it somewhere and then transfer it to your Red hat Enterprise Linux Server (RHEL). RHEL distro doesn’t have a GUI, but just CLI, so the easiest way might be to transfer via scp. Download the latest version and both the “basic” and “devel” RPMs.

After copying the instant client RPMs to your home directory, run the following commands to install the RPMs:

sudo rpm -Uvh oracle-instantclient12.1-basic*
sudo rpm -Uvh oracle-instantclient12.1-devel*

You then need to set the ORACLE_HOME environment variable:

cd ~
vi .bashrc

Install Pear & Devel

In order to install OCI8, you first need to get pecl. Also pecl will need the development packages. Run the following commands:

sudo yum install php70u-pear php70u-devel

Install OCI8

At this point you should be ready to install OCI8:

pecl install oci8

Observe the output carefully, and make sure no errors are shown. If any errors are shown, you might have to review the above to make sure you haven’t missed anything, also you might want to read through The Underground PHP Oracle Manual.

Then when oci8 is installed, you now need to edit the PHP config file to add the compiled file:

sudo vi /etc/php.ini

Add “” at the very bottom of the file.

Verifying OCI8 is Installed

First restart Apache:

sudo service httpd restart

Then create a phpinfo() file in your Apache Document root folder, so you can access it via web browser. Then open in any browser, and then search for “oci8”. Make sure that it is enabled.


About Alvin Bunk
Hi, I'm a software developer at Taft College.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: