RSS
 

Oracle PDO_OCI PHP install fedora CentOS

08 Oct

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.

Leave a Reply

Comments are closed

  1. very usefull

    November 17th 2009 at 09:11 am

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

    adobo

    Perfect

    December 17th 2009 at 03:12 am

    Worked here for RHEL 5.4. Thank you!
     

    thanks!

    February 24th 2010 at 06:02 am

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

    internet marketing

    Oracle PDO_OCI PHP install fedora CentOS

    October 23rd 2010 at 05:10 pm

    thanks, i'll try it too.
     

    Changes for x86_64

    November 10th 2010 at 09:11 am

    Some changes were required to get the configure to work on a 64 bit Redhat (Fedora 13) system.<br /> <br /> We installed the 64 bit version of oracle-instantclient-{devel,basic}.<br /> <br /> These installed in:<br /> /usr/lib/oracle/11.2/client64<br /> /usr/include/oracle/11.2/client64<br /> <br /> We created symlinks as follows:<br /> <br /> /usr/lib/oracle/11.2/client -> /usr/lib/oracle/11.2/client64<br /> /usr/include/oracle/11.2/client -> /usr/include/oracle/11.2/client64<br /> <br /> Then the "./configure --with-pdo-oci=instantclient,/usr,11.2" command worked fine!<br /> <br /> The reason for the symlinks instead of changing the variables in the oracle.sh is that the build/configure scripts seem to be hard coded for "client" (not client64) in many places. It was easer to create 2 symlinks than to change all the code in every script/config file.
     

    linuxine

    nice turial

    March 7th 2011 at 11:03 pm

    thanks very much,your tutorial helped me on set up my <a href=www.linuxine.com>centos </a> VPS