juin
02
2009

Oracle from PHP on Centos 5

1) install apache, php …

yum install httpd php php-mysql php-pear php-devel zlib zlib-devel
yum groupinstall « Development Tools »

2) Download and install oracle instant client (basic and devel) from there:

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html

rpm -Uvh oracle-instantclient-basic-<VERSION>.i386.rpm
rpm -Uvh oracle-instantclient-devel-<VERSION>.i386.rpm

3) Add the Oracle instant client to dynamic linker

echo /usr/include/oracle/<VERSION>/client/lib/ > /etc/ld.so.conf.d/oracle_client.conf
ldconfig -v

4) Untar the PECL package and prepare it for compiling

tar -xzvf oci-<VERSION>.tgz
cd oci-<VERSION>
phpize

5) Configure the PECL package as a shared object using the instant client and specifying where the Oracle client libraries are. Then build and install it.

./configure –with-oci8=shared,instantclient,/usr/lib/oracle/<VERSION>/client/lib
make
make install

6) Add the library shared object for PHP

echo extension=oci8.so > /etc/php.d/oci8.ini

7) Start Apache

‘service httpd start’ _or_ ‘/etc/init.d/httpd restart’

8) Create a PHP info page and checked to see if the Oracle (oci8) driver is listed:

echo <? phpinfo(); ?> > /var/www/html/phpinfo.php

Written by in: linux,oracle,php | Mots-clefs :, , , ,

14 commentaires »

  • kartnico dit :

    Just one mistake :

    echo /usr/lib/oracle//client/lib/ > /etc/ld.so.conf.d/oracle_client.conf

    Many thanks for this howto.

  • Jon dit :

    Thanks also from me for this HOWTO. On RHEL, I’d echo @kartnico, in that the path was very slightly modified. I found the following worked for me:

    echo /usr/include/oracle/11.2/client/ > /etc/ld.so.conf.d/oracle_client.conf

  • Willian Rocha dit :

    Where can I to download the file in the item 4?

  • admin dit :

    Oups, forgot to mention that.

    Here is what you are looking for:
    http://pecl.php.net/package/oci8

  • bossonaro dit :

    I make it but in step 5, the make command return error:
    #############################
    make: *** [oci8.la] Error 1
    #############################

    How to do?

  • admin dit :

    any other messages before that line? some dependencies missing?

  • TSHIMANGA dit :

    Hi,

    I followed the steps, with kartnico and then Jon comments.
    All the steps went well withoutany complain.
    The problem is that I can’t see any oci8 section while getting the phpinfo from a browser.
    Is there anything I missed, or missing the procedures?

    Regards,

    PS: RHEL 5.5, httpd 2.2.3, PHP 5.1.6, oci8 1.2.3

  • admin dit :

    Hi Tshimanga,
    if you have restarted apache then ou should check if « oci8.so » has been placed where it should.
    try:

    # updatedb
    # locate oci8.so

    you should have some like this

    /root/oci8-1.3.5/.libs/oci8.so
    /root/oci8-1.3.5/modules/oci8.so
    /usr/lib/php/modules/oci8.so

    if not then the pecl package has not been well installed.

  • braun1928 dit :

    Great! The EASIEST way ever to install OCI8 module. Thanks for the howto!

  • You just saved me *A LOT* of compiling ;D Thanks!

  • Camilo dit :

    Excelent, this is the best manual, better that Oracle offcial. Thank yuo

  • BluDragon dit :

    Beware of the « gotcha » when running SELinux. You’ll have to either set it to « Permissive » mode (setenforce 0) or execute the following commands:


    # grep http /var/log/audit/audit.log | audit2allow -M myhttp
    # semodule -i myhttp.pp

    See here for more information:
    http://stackoverflow.com/questions/5225236/oci8-extensions-load-in-cli-but-not-browser/5225771#5225771

  • Vijay dit :

    After doing all the steps, oci8 is still not listed in my php info page. I can see the following warning in the logs. How can I configure with the right version.

    [15-Sep-2011 14:10:39] PHP Warning: PHP Startup: oci8: Unable to initialize module
    Module compiled with module API=20060613, debug=0, thread-safety=0
    PHP compiled with module API=20050922, debug=0, thread-safety=0
    These options need to match

  • Randall Reynolds dit :

    Vijay, that error means the OCI connector you compiled comes from the wrong PHP version. Validate that the PHP version that you downloaded to build the OCI connector matches the web server’s PHP version.

RSS feed for comments on this post. TrackBack URL


Leave a Reply