tags:

views:

3191

answers:

5

On the latest Ubuntu, I have a functioning PHP 5.2.4 installation. I want to use a remote Oracle server from PHP using OCI. I've downloaded the "Instant Client Package - Basic Lite" from http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html. I've unzipped the package containing the OCI libraries to a dir but I have no idea how to tell PHP that I want to use these libraries. Predictably, I get "Fatal error: Call to undefined function oci_connect() in..." when running this code:

<?php 
   $conn = oci_connect('hr', 'hrpw', 'someremotehost');
?>

I don't want to recompile PHP with Oracle support. What's the fastest way to wire up PHP so that I can use Oracle? Do I need any other libaries, like the Oracle client if I want to connect to a remote Oracle instance?

+1  A: 

You need the PHP extension, try the following on your Ubuntu:

(sudo) pecl install oci8

Make sure your php.ini's (there should be one for your Apache and one for cli php) contain extension=oci8.so afterwards. Finally, you have to restart Apache and can confirm via <?php phpinfo(); ?> that the extension is loaded.

UPDATE:

Enter something like this when it asks you for ORACLE_HOME:

instantclient,/opt/oracle/instantclient

I think setting the environment variable would be another solution. /opt/oracle... is the path I put my instantclient in. I followed some tutorial a while ago, unfortunately I can't find it anmore.

HTH

Till
A: 

I tried "(sudo) pecl install oci8" and I get:

checking Oracle version... configure: error: Oracle client libraries not found ERROR: `/tmp/pear/cache/oci8-1.3.4/configure --with-oci8' failed

How do I get over that?

Sajee
I updated my answer. You should use comments to ask questions.
Till
A: 

pecl still errors out with "checking Oracle version... configure: error: Oracle client libraries not found" even after "export ORACLE_HOME=instantclient,/opt/oci"

Other than OCI, do I need any other Oracle libraries? OCI is the only Oracle related library on the machine. Do I need Oracle client libraries or anything else?

Sajee
A: 

I think you'll need to make sure that the $ORACLE_HOME/lib32 is in your $LD_LIBRARY_PATH, or else add that directory to the /etc/ld.so.conf file.

m0j0
+1  A: 

In the end, I downloaded Zend Core for Oracle and that worked. http://www.zend.com/en/products/core/for-oracle

Sajee
Don't use zend core for oracle, use the generic version (it has oracle support). I had a support ticket because of bugs in zend core for oracle and they told me it is deprecated and no longer actively updated.
Joeri Sebrechts