Tuesday, May 20, 2014

Apache + PHP + Oracle + Linux

It is good to be back. I hope I can be more consistent. Most of my days work centers on the subject of this post.

PHP, Apache, Linux and Oracle. MySQL is the database is use for most of the projects I undertake mainly due to ease of use and also the scale of the projects.

In this post I will be talking about adding Oracle to the list of supported database on  PHP. The operating system on which the setup was done is Open Suse 11 64 bit.

The steps are are follows.

Download instantclient-basic-linux.x64-12.1.0.1.0-1.x86_64.rpm or rpm version and instantclient-sdk-linux.x64-12.1.0.1.0-1.x86_64.rpm header files from www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Install the rpms.

rpm -ivh instantclient-basic-linux.x64-12.1.0.1.0-1.x86_64.rpm
rpm -ivh instantclient-sdk-linux.x64-12.1.0.1.0-1.x86_64.rpm

The first RPM puts Oracle libraries in /usr/lib/oracle/12.1/client64/lib and the second creates headers in /usr/include/oracle/12.1/client64.

Install header files for php and install gcc

yum install php-devel
yum install gcc

Now install Oracle OCI8 extensions

pecl install oci8

Add the Instant Client directory to apache2 under /etc/sysconfig

cd /etc/sysconfig
vi apache2
add export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib

Restart apache

service apache2 restart

Verify oci8 extention by creating a php file containing the function below

phpinfo();