Page 1 of 7 123 ... LastLast
Results 1 to 10 of 66

Thread: Howto: Install Oracle Instant Client and PHP OCI8 module

  1. #1
    Join Date
    Dec 2004
    Location
    Bonn, Germany
    Beans
    6
    If you want to connect to an Oracle database with PHP, you can use Oracle's Instant Client and the oci8 module from pear.

    Download the Basic and the SDK packages from http://www.oracle.com/technology/tec...antclient.html. At the time of this writing, the filenames are instantclient-basic-linux32-10.2.0.1-20050713.zip and instantclient-sdk-linux32-10.2.0.1-20050713.zip.

    Unzip these files in a new directory, e.g. /opt/oracle/instantclient.

    Code:
    mkdir -p /opt/oracle/instantclient
    cd /opt/oracle/instantclient
    unzip instantclient-basic-linux32-10.2.0.1-20050713.zip
    unzip instantclient-sdk-linux32-10.2.0.1-20050713.zip
    echo /opt/oracle/instantclient >> /etc/ld.so.conf
    ldconfig
    The previous two lines are supposed to create symlinks named libclntsh.so and libocci.so which we will need later. In my case these symlinks were not created by ldconfig, so I created them manually.

    Code:
    ln -s libclntsh.so.10.1 libclntsh.so
    ln -s libocci.so.10.1 libocci.so
    In the next step we will download the oci8 module with pear. Pear is in the php-pear package.

    Code:
    apt-get install php-pear
    "Normally" we should be able to just use pear install oci8 now, but apparently pear is not able to figure out where the instantclient libraries are. So we will just download the oci8 module and build it on our own.

    Code:
    mkdir -p /usr/local/src
    cd /usr/local/src
    pear download oci8
    tar xzf oci8-1.1.1.tgz
    cd oci8-1.1.1
    phpize
    ./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient
    make
    make install
    The oci8-1.1.1.tgz filename will of course change for newer releases.
    To enable the oci8 module in the php.ini (/etc/php5/apache2/php.ini and /etc/php5/cli/php.ini), add a line
    Code:
    extension=oci8.so
    (put this line after the examples starting with ;extension).

    Now stop and start Apache. You should see the oci8 module in the output of phpinfo().

  2. #2
    Join Date
    Mar 2005
    Location
    San Francisco, US
    Beans
    139
    Distro
    Hardy Heron (Ubuntu Development)

    Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    I've followed the instructions, but get the following error when running the ./configure command. Do I need version 3.4 or something (I've seen as a problem elsewhere)?

    checking how to run the C++ preprocessor... /lib/cpp
    configure: error: C++ preprocessor "/lib/cpp" fails sanity check


    Thanks, Tom
    Dell Inspiron 1420n running Hardy i386.

  3. #3
    Join Date
    Mar 2005
    Location
    San Francisco, US
    Beans
    139
    Distro
    Hardy Heron (Ubuntu Development)

    Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    Solved with:

    sudo apt-get install build-essential

    Thanks, Tom
    Dell Inspiron 1420n running Hardy i386.

  4. #4
    Join Date
    Apr 2006
    Beans
    2

    Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    for phpize use:


    sudo apt-get install php5-dev

  5. #5
    Join Date
    Jul 2006
    Beans
    1

    Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    An excellent howto! Thanks - you've really saved me!

    I tried with the basiclite version that oracle makes available and it didn't work very well (at all) - the issue was that it's missing the libociei.so library.

    Be sure to use the full basic client. Currently instantclient-basic-linux32-10.2.0.2-20060331.zip

    I also had to set the environ a little as well:
    export LD_LIBRARY_PATH=/opt/oracle/instantclient/

    Good luck!

  6. #6
    Join Date
    Jul 2006
    Location
    Vladivostok, Russia
    Beans
    1

    Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    At least with Ubuntu 6.06 and oci8-1.2.1 you don't need to compile oci8 extension manually. Just run:
    Code:
    pecl install oci8
    and enter "instantclient,/opt/oracle/instantclient" when it'll prompt for the path to ORACLE_HOME dir

  7. #7
    Join Date
    Dec 2005
    Beans
    3

    Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    Is the module supposed to show up in phpinfo after its installed?

  8. #8
    Join Date
    Dec 2005
    Beans
    3

    Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    Quote Originally Posted by ehudokai View Post
    Is the module supposed to show up in phpinfo after its installed?
    OK, in answer to my own question there are two extra things I had to do.

    in /etc/php5/apache2/php.ini (since I'm using the php_mod) :
    Code:
    extension=oci8.so
    has to be put in there...

    For me also, I had to add www-data to the oinstall group to give it access to my oracle files...

    Hope that helps someone

  9. #9
    Join Date
    Apr 2005
    Location
    Illinois
    Beans
    272

    Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    How do I connect to Oracle? I installed everything as said above. I now want to connect to Oracle and see if it works.

    ps: I have Oracle XE also installed, so I'm not sure if it will affect the Oracle instant client or it can co-exist with Oracle instant client.

    Edit:
    Sorry for the confusion. I didn't realize that Oracle instant client is to connect PHP to Oracle Databas. I have Oracle XE installed. Are there any environment variable that needs to be set to access the Oracle XE database I installed?
    Last edited by arunsub; July 26th, 2006 at 02:01 AM.
    ===============================
    My Blog: http://www.blog.arun-prabha.com/
    My Home: http://www.arun-prabha.com
    ===============================

  10. #10
    Join Date
    Feb 2006
    Location
    South Africa
    Beans
    41
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Wink Re: Howto: Install Oracle Instant Client and PHP OCI8 module

    As mentioned at http://forums.oracle.com/forums/thre...04923&tstart=0
    you set environment variables for Oracle 10g XE in Linux by :-
    source /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

    this could also be done as
    . /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

    but don't make the same mistake that I did by leaving out the dot space at the beginning of the above line.

    My question is, does this overall solution work for getting OCI8 to access local Oracle databases? I thought instantclient was only for remote DataBases.
    Last edited by Alf Stockton; July 26th, 2006 at 09:45 AM. Reason: misspelling etc
    Regards,
    Alf Stockton

Page 1 of 7 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •