How to install OCI8 (PHP extension to access Oracle Databases) on a RHEL / Fedora Linux system.

Download from http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html :

EDIT 2013/09/24 : http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

  • RPM Instant Client Package – SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
  • RPM Instant Client Package – Basic: All files required to run OCI, OCCI, and JDBC-OCI applications

Install both RPM packages :

rpm -ivh instantclient-basic-linux.XXX.rpm
rpm -ivh instantclient-sdk-linux.XXX.rpm

Install some prerequisite

yum install php-pear
yum install php-devel

Download the OCI8 extension

pear download pecl/oci8
tar xvzf oci8-1.4.7.tgz
cd oci8-1.4.7/
phpize

Configure the extension with your Oracle client library path (change the path …/11.2/… with your own version) :

./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib/

Compil and install

make
make install

Configure SELinux : allows httpd to execute programs that require memory addresses that are both executable and writeable

setsebool -P httpd_execmem 1

Add the folowing configuration at the end of php.ini

vi /etc/php.ini
[OCI8]
extension=oci8.so

Restart Apache

service httpd restart

That’s all folks.