Oracle PDO_OCI PHP install fedora CentOS

Well i run a mix of CentOS and Fedora machines, and at work i needed to run some reports from an Oracle DB. I really don't care much for Oracle, but i needed to get the data, and since i don't like having to do the same thing over again i thought i would just throw together a PHP page and let the user run the canned report themselves. However getting Oracle to install on CentOS and my Fedora boxes was not a simple yum install...

So here are my steps on how i got pdo_oci to install on my machine using PHP 5.2.x

Instant Client 

You will first need to download the instant client from oracle website. I am using that link because you may have a x86_64 machine or just a x86. That page will let you choose. You will need to install the following packages

  1. oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm
  2. oracle-instantclient11.2-devel-11.2.0.1.0-1.i386.rpm

Run yum -y --nogpgcheck install oracle-instantclient*  to install the packages. You can now go to the next section

Oracle Profile

Run the following command to create oracle.sh profile in profile.d directory

cat <<EOF > /etc/profile.d/oracle.sh

export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib/
export ORACLE_HOME=/usr/lib/oracle/11.2/client/lib/
EOF

Then run

[root@ed-mann]# source /etc/profile.d/oracle.sh

Note:

I did change my ORACLE_HOME to /usr/include/oracle/11.2/client. I am not sure if it did anything, i am planning on testing without doing that.

PDO_OCI SRC

 

To get the oracle PDO driver install on Linux you will need to get the src from pecl

[root@ed-mann tmp]# pecl download pdo_oci

Patch

 

Then once you have it you need to edit the config.m4 file and add the following after exploding the src look for similar sections

elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.2; then
PDO_OCI_VERSION=11.2

also add the following

11.2)
PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
 ;;

Again look for a similar area and add that. I may provide a patch. I did see a patch here. But it did not work for me... well it probably would have but by the time i figured this all out i was not using that patch.

Compile

Now you can run phpize and then this configure command

./configure  --with-pdo-oci=instantclient,/usr,11.2

Since we are using the instantclient we need to put that also we add what version we are using.

Now you can run make &&  make install as root

Include File

Create a new file in /etc/php.d named pdo_oci.ini and include the following

; Enable pdo_oci (oracle) extension module
extension=pdo_oci.so

Final Steps

Now you will need to reload/restart Apache. Put phpinfo(); in a page view it from your browser. You should see PDO_OCI listed if not i don't know what went wrong. Leave me a message and i will help if i can.

 

3 Responses to "Oracle PDO_OCI PHP install fedora CentOS"

hi, thanks, i try in centos 5.4 and no problem

Worked here for RHEL 5.4. Thank you!

hello!, thank you so much! works on centos 5.3

Leave a Reply

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code,samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>

 

 
This page took 0.310824 seconds to load.