Setting up PHP to use Oracle Instant Client (oci8) under RHEL/Fedora/CentOS distributions

AID: 639
  • Status: Published

5500 points

  • By
  • TypeTutorial
  • Posted on2009-05-14 at 08:49:24
Currently, there is not an RPM package available under the RHEL/Fedora/CentOS distributions that gives you a quick and easy way to allow PHP to interface with Oracle. As a result, I have included a set of instructions on how to do this with minimal time and effort.

To complete the steps, you you will need to get the Oracle Instant Client and the OCI8 PECL package.

Oracle Instant Client: http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
PECL OCI8 Package: http://pecl.php.net/package/oci8

1) Install Apache, PHP, the Oracle Instant Client MySQL support if you want it and required development packages to build from source code.

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

2) Add the Oracle instant client to dynamic linker

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

3) Untar the PECL package and prepare it for compiling

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

4) 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

5) Add the library shared object for PHP

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

6) Start Apache

    'service httpd start' _or_ '/etc/init.d/httpd restart'

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

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

Asked On
2009-05-14 at 08:49:24ID639
Tags

Oracle

,

RPM

,

Red Hat

,

CentOS

,

PHP

,

Fedora

Topic

Linux

Views
11100

Comments

Author Comment

by: mwecomputers on 2009-05-14 at 14:54:58ID: 951

Instruction #1: Under RedHat Linux defined distributions (i.e. CentOS, RHEL, Fedora), 'yum' [Yellow dog Updater, Modified (YUM)] is an open-source command-line package-management utility for RPM-compatible Linux operating systems.

Instruction #3: Tar (Tape Archiver) is both a file format (in the form of a type of archive bitstream) and the name of the program used to handle such files. The use of 'tar -zxvf <filename>.tgz' will uncompress the 'tarball', then extract the files & directories into the directory the file is originally located in.

Instruction #6: There are two ways to do it under RedHat Linux: 'service httpd start' _or_ '/etc/init.d/httpd restart'

Add your Comment

Please Sign up or Log in to comment on this article.

Join Experts Exchange Today

Gain Access to all our Tech Resources

Get personalized answers

Ask unlimited questions

Access Proven Solutions

Search 3.2 million solutions

Read In-Depth How-To Guides

1000+ articles, demos, & tips

Watch Step by Step Tutorials

Learn direct from top tech pros

And Much More!

Your complete tech resource

See Plans and Pricing

30-day free trial. Register in 60 seconds.

Loading Advertisement...

Top Linux Experts

  1. arnold

    331,375

    Wizard

    750 points yesterday

    Profile
    Rank: Genius
  2. woolmilkporc

    279,119

    Guru

    2,668 points yesterday

    Profile
    Rank: Genius
  3. farzanj

    132,548

    Master

    0 points yesterday

    Profile
    Rank: Genius
  4. KeremE

    109,627

    Master

    0 points yesterday

    Profile
    Rank: Genius
  5. duncan_roe

    105,116

    Master

    0 points yesterday

    Profile
    Rank: Genius
  6. hanccocka

    99,734

    Master

    1,500 points yesterday

    Profile
    Rank: Genius
  7. legolasthehansy

    74,904

    Master

    0 points yesterday

    Profile
    Rank: Guru
  8. xterm

    65,407

    Master

    0 points yesterday

    Profile
    Rank: Sage
  9. Papertrip

    59,708

    Master

    0 points yesterday

    Profile
    Rank: Sage
  10. DaveBaldwin

    55,260

    Master

    0 points yesterday

    Profile
    Rank: Genius
  11. TobiasHolm

    46,700

    0 points yesterday

    Profile
    Rank: Sage
  12. rindi

    43,404

    0 points yesterday

    Profile
    Rank: Savant
  13. ahoffmann

    41,621

    0 points yesterday

    Profile
    Rank: Genius
  14. noci

    40,754

    0 points yesterday

    Profile
    Rank: Genius
  15. gerwinjansen

    38,789

    0 points yesterday

    Profile
    Rank: Sage
  16. Darr247

    38,657

    0 points yesterday

    Profile
    Rank: Genius
  17. chandranjoy

    36,828

    0 points yesterday

    Profile
    Rank: Master
  18. torakeshb

    33,696

    0 points yesterday

    Profile
    Rank: Master
  19. pfrancois

    33,520

    0 points yesterday

    Profile
    Rank: Guru
  20. un1x86

    30,652

    0 points yesterday

    Profile
    Rank: Master
  21. maeltar

    30,550

    0 points yesterday

    Profile
    Rank: Guru
  22. ozo

    24,100

    0 points yesterday

    Profile
    Rank: Savant
  23. jgiordano

    23,700

    0 points yesterday

    Profile
    Rank: Guru
  24. for_yan

    23,600

    1,000 points yesterday

    Profile
    Rank: Genius
  25. bummerlord

    23,300

    0 points yesterday

    Profile
    Rank: Master

Hall Of Fame