Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 66

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

  1. #21
    Join Date
    Oct 2007
    Beans
    2

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

    Hi ,
    enter I didl this command "pecl install oci8"
    I got this error ?
    /usr/bin/ld: skipping incompatible /opt/oracle/instantclient//libclntsh.so when searching for -lclntsh
    /usr/bin/ld: cannot find -lclntsh
    collect2: ld returned 1 exit status
    make: *** [oci8.la] Error 1
    ERROR: `make' failed

    Could you help me ?

  2. #22
    Join Date
    Oct 2007
    Beans
    2

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

    Hi ,
    When I tried this command "pecl install oci8"
    I got this error ?
    /usr/bin/ld: skipping incompatible /opt/oracle/instantclient//libclntsh.so when searching for -lclntsh
    /usr/bin/ld: cannot find -lclntsh
    collect2: ld returned 1 exit status
    make: *** [oci8.la] Error 1
    ERROR: `make' failed

    Could you help me ?

  3. #23
    Join Date
    Oct 2007
    Location
    South Africa
    Beans
    9
    Distro
    Kubuntu

    Lightbulb Re: Howto: Install Oracle Instant Client and PHP OCI8 module (summary)

    this forum helped me a lot but it was a little incoherent and outdated, so here is the steps that worked for me (mostly copied from other posts):


    * sudo apt-get install apache2 php5 php5-dev
    * download oracle instant client from oracle and install.
    * to get php and oci working:
    Code:
     su
     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
    
     apt-get install php-pear
    
     pecl install oci8
    * To enable the oci8 module in the php.ini (/etc/php5/apache2/php.ini and /etc/php5/cli/php.ini), add a line Code:
    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().

  4. #24
    Join Date
    Oct 2007
    Beans
    1

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

    Quote Originally Posted by msalahat View Post
    Hi ,
    enter I didl this command "pecl install oci8"
    I got this error ?
    /usr/bin/ld: skipping incompatible /opt/oracle/instantclient//libclntsh.so when searching for -lclntsh
    /usr/bin/ld: cannot find -lclntsh
    collect2: ld returned 1 exit status
    make: *** [oci8.la] Error 1
    ERROR: `make' failed

    Could you help me ?
    I have the same problem. I'm pretty much flying blind on CLI, so any help would be appreciated greatly.

    Obviously I need to find and load "make", but don't know where to look or what command to run.

    UPDATE: n/m, I ran apt-get build-essential..........resolved the issue.
    Last edited by chrisHHR; November 6th, 2007 at 04:52 PM.

  5. #25
    Join Date
    Feb 2007
    Location
    Bend, OR
    Beans
    20
    Distro
    Ubuntu Karmic Koala (testing)

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

    ///NOTES///

    HOWTO: Install Apache2 + PHP5 + InstantClient + oci8 on Ubuntu 7.10

    Overall Objective: Install PHP5, APACHE2, with Instant Client 11.1 and oci8 libraries in order to connect remotely with an Oracle DB.

    Personal Objective:
    I use PHP to interface with several Oracle databases. My scripts will run and extract data for me and then perform a multitude of tasks using the data.

    OS Version: Ubuntu 7.10 i386 Desktop

    Target Audience: Nerds who have a basic understanding of the command line, compiling, and PHP. If your skill exceeds this then you can still follow along, but you probably could skip some steps.

    SUPPORT: I will support this document with updates should others post their findings. I will also do my best to answer questions DIRECTLY related to this doc

    Note#1: After setting this process up, I reinstalled Ubuntu and went through the process again, step by step, in order to maintain accuracy.

    Note#2: After logging into Ubuntu, I issue a sudo –i command in order to maintain my root id throughout the installation process.

    Note#3: I originally worked off Elmicha's doc until I ran into issues. So I created this doc at length to give a little deeper insight.

    Note#4: Original .txt is attached to this post should others want to work off of it. Please site myself and Elmicha please.

    ///BEGIN SETUP///

    Login to a Terminal and issue a sudo -i

    Code:
    test@ubuntu-desktop:~$ sudo -i
    Install Apache2

    Code:
    root@ubuntu-desktop:~# apt-get install apache2
    Install required PHP5 modules and libraries

    Code:
    root@ubuntu-desktop:~# apt-get install php5-common php5 php5-dev libapache2-mod-php5 php5-cli
    Install the build-essential and php-pear packages

    Code:
    root@ubuntu-desktop:~# apt-get install build-essential php-pear
    IMPORTANT! Install libaio1 library. This is what I was having serious issues with originally.

    Code:
    root@ubuntu-desktop:~# apt-get install libaio1
    Download the new Instantclient and SDK zip files from Oracle.

    http://www.oracle.com/technology/tec...ent/index.html

    In my case the files are called Basic.zip and Sdk.zip Initially these files will be saved in my home directory under the Documents folder.
    Code:
    /home/ubuntu/Documents/
    create a directory to house the zip files once they are uncompressed

    Code:
    root@ubuntu-desktop:~# mkdir /opt/oracle
    move the .zip files in the “Documents” directory to the /opt/oracle directory

    Code:
    root@ubuntu-desktop:~# mv /home/ubuntu/Documents/*.zip /opt/oracle
    Change to the /opt/oracle directory

    Code:
    root@ubuntu-desktop:~# cd /opt/oracle
    Unzip the files

    Code:
    root@ubuntu-desktop:/opt/oracle# unzip \*.zip
    rename instantclient directory
    Code:
    root@ubuntu-desktop:/opt/oracle# mv instantclient_11_1 instantclient
    Change directory to instantclient, list the files
    Code:
    root@ubuntu-desktop:/opt/oracle# cd instantclient
    Create symbolic links
    Code:
    root@ubuntu-desktop:/opt/oracle# ln –s libclntsh.so.11.1 libclntsh.so
    root@ubuntu-desktop:/opt/oracle# ln –s libocci.so.11.1 libocci.so
    Create a source directory under /opt/oracle . This is where we will house the oci8 libraries.
    Code:
    root@ubuntu-desktop:/opt/oracle# mkdir /opt/oracle/src
    Change the directory to /opt/oracle/src and download the oci8 tar using pecl
    Code:
    root@ubuntu-desktop:/opt/oracle# cd /opt/oracle/src
    Code:
    root@ubuntu-desktop:/opt/oracle/src# pecl download oci8
    Untar the oci8 libraries
    Code:
    root@ubuntu-desktop:/opt/oracle/src# tar xvf oci8-1.2.4.tgz
    Change to the newly created oci8-1.2.4 directory and issue the following commands
    Code:
    root@ubuntu-desktop:/opt/oracle/src# cd oci8-1.2.4
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# phpize
    Set the ORACLE_HOME environment variable
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# export ORACLE_HOME=/opt/oracle/instantclient
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# echo $ORACLE_HOME
    /opt/oracle/instantclient
    Configure oci8 to install with the necessary parameters
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# ./configure --with-oci8=share,instantclient,/opt/oracle/instantclient
    run make to compile
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# make
    install oci8
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# make install
    insert the extension=oci8.so into the php.ini and cli.ini files
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# echo extension=oci8.so >> /etc/php5/apache2/php.ini
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# echo extension=oci8.so >> /etc/php5/cli/php.ini
    restart apache
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# /etc/init.d/apache2 restart
    create a phpinfo.php file in /var/www
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# vi /var/www/phpinfo.php
    Now go to your browser and run the phpinfo file and look for the oci8 module

    Code:
    http://localhost/phpinfo.php
    Create a empty script to test your Oracle Connection
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# vi /home/ubuntu/oratest.php
    Copy and Paste this PHP code into your script and change the variables accordingly
    PHP Code:
    <?php

    //oracle connection variables
    $ora_user =     'YOUR_USERNAME';    //username
    $ora_pass =    'YOUR_PASS';            //user password
    $ora_host =    'SERVER_IP_OF_ORACLE"';        //host name or server ip address
    $ora_db   =     'YOUR_DATABASE';    //database name

    // place variable into oci_connect function, then place funtion in variable
    $ora_conn oci_connect($ora_user,$ora_pass,'//'.$ora_host.'/'.$ora_db);

    // error handling
    if (!ora_conn){                            // if variable $ora_conn fails to connect
    // do the following if it fails
    $ora_conn_erno oci_error();             // insert oci_error() function into variable
    echo ($ora_conn_erno['message']."\n");     // print the $ora_conn_erno variable/oci_error() function selecting only the message (human readable)
    oci_close($ora_conn);                     // close the connection just in case php doesn't close it
    } else {
    // if it doesn't fail it will proceed with the rest of the script
    echo "Connection Succesful\n";     //echo message if connection does not error
    oci_close($ora_conn);             // close the connection
    }

    ?>
    Test the connection
    Code:
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4# php /home/ubuntu/oratest.php
    Connection Succesful
    root@ubuntu-desktop:/opt/oracle/src/oci8-1.2.4#
    *Merry Christmas
    elvis
    Attached Files Attached Files
    Last edited by backwardselvis; December 19th, 2007 at 09:09 PM. Reason: Syntax changes and html characters that were displaing in the php script

  6. #26
    Join Date
    Feb 2006
    Beans
    Hidden!
    Distro
    Kubuntu 7.10 Gutsy Gibbon

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

    Absolutely tremendous!
    Thank you!

  7. #27
    Join Date
    Oct 2005
    Beans
    22

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

    you made my Christmas, thank you

  8. #28
    Join Date
    Nov 2006
    Beans
    38

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

    Thanks Elvis!!
    Finally got it to work! My problem was the missing libaio1 package
    But now I'm getting this warning:
    Code:
    Warning: oci_connect() [function.oci-connect]: ORA-12541: TNS:no listener in /var/www/lixo.php on line 10
    Any help?

  9. #29
    Join Date
    Feb 2007
    Location
    Bend, OR
    Beans
    20
    Distro
    Ubuntu Karmic Koala (testing)

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

    Glad everyone likes it. It took me almost a week to figure out what the hell was going on.

    Vudu, is this a fresh install following the steps?

    Can you query the DB and extract data?

    You could suppress the error with the @ symbol but that really would be just to patch it and not a real fix.
    Last edited by backwardselvis; December 19th, 2007 at 09:26 PM.

  10. #30
    Join Date
    Nov 2006
    Beans
    38

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

    Now i get a
    Warning: oci_connect() [function.oci-connect]: ORA-03134: Connections to this server version are no longer supported. in /var/www/lixo.php on line 17
    So, it seems to be a server-side issue...

    and...
    Connection Succesful
    Warning: oci_parse() expects parameter 1 to be resource, boolean given in /var/www/lixo.php on line 39

    Warning: oci_execute() expects parameter 1 to be resource, null given in /var/www/lixo.php on line 40

    Warning: oci_fetch_row() expects parameter 1 to be resource, null given in /var/www/lixo.php on line 42

    Warning: oci_close() expects parameter 1 to be resource, boolean given in /var/www/lixo.php on line 52
    That's weird

Page 3 of 7 FirstFirst 12345 ... 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
  •