Kurulum

Configuring PHP with OCI8

To enable the OCI8 extension, configure PHP with the option
--with-oci8
.

Before starting the web server, OCI8 typically requires several
Oracle environment variables (see below) to locate libraries, point
to configuration files, and set some basic properties such as the
character set used by Oracle libraries. The variables must be set
before any PHP process starts.

The PHP binary must link with the same, or more recent, major version of
Oracle libraries as it was configured with. For example, if you build
OCI8 with Oracle 11.2 libraries, then PHP should also be deployed
and run with Oracle 11.2 libraries. PHP applications can connect to other
versions of Oracle Database, since Oracle has client-server cross-version compatibility.

Installing OCI8 as a Shared Extension

The configuration shared option
builds OCI8 as a shared library that can be dynamically loaded into
PHP. Building a shared extension allows OCI8 to be upgraded easily
without impacting the rest of PHP.

For example, --with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client/lib

Note that Oracle Instant Client support first appeared in PHP
4.3.11 and 5.0.4 and originally used the option
--with-oci8-instant-client
to
configure PHP.

If using an Oracle database or full Oracle Client installation then do:

./configure --with-oci8=shared,$ORACLE_HOME

Make sure the web server user
(nobody, www) has access to
the libraries, initialization files
and tnsnames.ora (if used) under
the $ORACLE_HOME directory. With Oracle
10gR2, you may need to run
the $ORACLE_HOME/install/changePerm.sh
utility to give directory access.

After configuration, follow the usual PHP building procedure,
e.g. make install. The OCI8 shared extension
oci8.so library will be created. It may need
to be manually moved to the PHP extension directory, specified by
the extension_dir option in
your php.ini file.

To complete installation of OCI8, edit php.ini and add the line:

extension=oci8.so

Installing OCI8 as a Statically Compiled Extension

Configure PHP to include OCI8 using one of the following configure options.

If using Oracle Instant Client, then do:

./configure --with-oci8=instantclient,/path/to/instant/client/lib

If using an Oracle database or full Oracle Client installation then do:

./configure --with-oci8=$ORACLE_HOME

After configuration, follow the usual PHP building procedure,
e.g. make install. After successful
compilation, you do not need to add oci8.so to
php.ini. No additional build steps are required.

Installing OCI8 from PECL

The OCI8 extension can be added to an existing PHP installation
either automatically or manually
from » PECL.

For an automated install follow these steps:

If you are behind a firewall, set PEAR's proxy, for example:

pear config-set http_proxy http://my-proxy.example.com:80/

Run

pecl install oci8

When prompted, enter either the value of $ORACLE_HOME, or
instantclient,/path/to/instant/client/lib.

Note: Do not enter the variable $ORACLE_HOME
because it will not be expanded. Instead, enter the actual path
of the Oracle home directory.

For a manual install when the pecl command is not
available, download the PECL OCI8 package, e.g. oci8-1.4.10.tgz.

After either an automatic or manual install, edit your php.ini
file and add the line:

extension=oci8.so

Make sure the php.ini
directive extension_dir is
set to the directory that oci8.so was installed
in.

Installing OCI8 on Windows

When using Oracle 10gR2 client libraries on
Windows, uncomment the php.ini
line extension=php_oci8.dll. When using Oracle
11gR2 or later client libraries, uncomment
extension=php_oci8_11g.dll
or extension=php_oci8.dll. With Oracle
12c libraries
use extension=php_oci8_12c.dll
or extension=php_oci8_11g.dll
or extension=php_oci8.dll. Only one of these DLLs
may be enabled at a time. DLLs with higher versions may contain more
functionality. Not all DLLs may be available for all versions of
PHP. Make
sure extension_dir is set
to the directory containing the PHP extension DLLs.

If using Instant Client, set the system PATH
environment variable to the Oracle library directory.

Setting the Oracle Environment

Before using this extension, make sure that the Oracle environment
variables are properly set for the web daemon user. If your web
server is automatically started at boot time then make sure that the
boot-time environment is also configured correctly.

Bilginize:

Do not set Oracle environment variables
using putenv() in a PHP script because Oracle
libraries may be loaded and initialized before your script
runs. Variables set with putenv() may then cause
conflicts, crashes, or unpredictable behavior. Some functions may
work but others might give subtle errors. The variables should be
set up before the web server is started.

On Red Hat Linux and variants, export variables at the end of
/etc/sysconfig/httpd. Other systems with
Apache 2 may use an envvars script in the
Apache bin directory. A third option, the
Apache SetEnv directive
in httpd.conf, may work in some systems but is
known to be insufficient in others.

To check that environment variables are set correctly,
use phpinfo() and check
the Environment (not the Apache
Environment) section contains the expected variables.

The variables that might be needed are included in the following
table. Refer to the Oracle documentation for more information on
all the available variables.

Common Oracle Environment Variables

Name

Purpose

ORACLE_HOME

Contains the directory of the full Oracle Database
software. Do not set this when using Oracle Instant Client as
it is unnecessary and may cause installation problems.

ORACLE_SID

Contains the name of the database on the local machine to
be connected to. There is no need to set this if you using
Oracle Instant Client, or always pass the connection parameter
to oci_connect().

LD_LIBRARY_PATH

Set this (or its platform equivalent, such
as DYLD_LIBRARY_PATH, LIBPATH,
or SHLIB_PATH) to the location of the Oracle
libraries, for example $ORACLE_HOME/lib
or /usr/lib/oracle/11.1/client/lib. This
variable is not needed if the libraries are located by a
different search mechanism, such as
with ldconfig or
with LD_PRELOAD.

NLS_LANG

This is the primary variable for setting the character
set and globalization information used by the Oracle
libraries.

ORA_SDTZ

Sets the Oracle session timezone.

TNS_ADMIN

Contains the directory where the Oracle Net Services
configuration files such as tnsnames.ora
and sqlnet.ora are kept. Not needed if
the oci_connect() connection string uses the
Easy Connect naming syntax such
as localhost/XE. Not needed if the network
configuration files are in one of the default locations such
as $ORACLE_HOME/network/admin
or /etc.

Less frequently used Oracle environment variables include
TWO_TASK, ORA_TZFILE, and the
various Oracle globalization settings
like NLS* and the ORA_NLS_*
variables.

Troubleshooting

The most common problem with installing OCI8 is not having the
Oracle environment correctly set. This typically appears as a
problem using oci_connect()
or oci_pconnect(). The error may be a PHP error
such as Call to undefined function
oci_connect(), an Oracle error such as ORA-12705, or even
an Apache crash. Check the Apache log files for startup errors and
see the sections above to resolve this problem.

While network errors like ORA-12154 or ORA-12514 indicate an Oracle
network naming or configuration issue, the root cause may be because
the PHP environment is incorrectly set up and Oracle libraries are
unable to locate the tnsnames.ora configuration
file.

On Windows, having multiple versions of Oracle on the one machine
can easily cause library clashes unless care is taken to make sure
PHP only uses the correct version of Oracle.

A utility to examine what libraries are being looked for and loaded
can help resolve missing or clashing library issues, particularly on
Windows.

User Contributed Notes 46 notes

If you've followed the instructions and you can't even connect to the DB server, welcome to the Oracle hell. Most of the information you'll find is deprecated, incomplete, not for your platform, unnecessary or just plain wrong.

Typically, you won't need at all those complicate setups you'll read about and they'll probably make things harder. I suggest you get Systernal's "Filemon" utility (for Windows, in Unix you may do with strace) and find out what exact config files and DLLs are being tried by php.exe (or httpd.exe if PHP runs as Apache module or...). Pretty often, the issue is that (e.g.) TNSNAMES.ORA does not have the correct line ending or Apache is looking for a DLL that does not even exist in your hard disc; learning that prevents you to waste time adding more and more useless environmental variables.

Lost a day on trying to make work oci8 & pdo_oci extensions in php-fpm 5.3 on OpenSuSE 12.2 (64bit) with latest oracle instant client 11.2.0.3.0. Any of two works normally with generic instructions. But both extensions caused crash in oci_connect().

Warning: ocilogon(): _oci_open_session: OCIHandleAlloc OCI_HTYPE_SVCCTX: OCI_INVALID_HANDLE can also be caused by running the webserver with an ORACLE_HOME of a (radically?) different version than PHP was linked against.

I experienced this when I accidently used an Oracle 8 ORACLE_HOME for a PHP that was linked against Oracle 9.

I've had all kinds of errors with RedHat9(yuck), PHP 4.3.4RC1 and Oracle enterprice server 9.2. For some time I thought that --with-oci8 wouldn't work with Oracle9 but that wasn't the case, the solution was many steps.

4) Configure Apache. For some reason it requires some tweaking with environment variables, in the begining I put those in the PHP-script with putenv, later in the httpd.conf with SetEnv and the mod_env module. But I was told to not do that and instead set them in the init script for Apache. So I copied apachectl to /etc/init.d and edited envvars in $APACHE_PATH/bin. First I added all kinds of env variables until I got it to work, and then I removed them one at a time and came to the following minimal configuration:
LD_LIBRARY_PATH="/usr/local/apache2/lib:$LD_LIBRARY_PATH"
ORACLE_HOME=/opt/ora9/product/9.2
LANG=sv_SE
export LD_LIBRARY_PATH ORACLE_HOME LANG

Earlier I had added NLS_LANG and TNS_ADMIN above those mentioned above (point 1), but it seems those aren't needed really. So no need for TWO_TASK or ORACLE_SID, only needed one is ORACLE_HOME and if you get missing/invalid option for your OCILogon set LANG to something else like I did. Someone earlier said it might have to do with UTF8.

So if you are sure lsncrtl are started and that you have the correct env-variables set in your $APACHE_PATH/bin/envvars you can just use something like:

For example on UNIX systems /etc/init.d/apache would contain following lines before anything else:

#!/bin/bash

if [ -f ~oracle/.profile ]; then
source ~oracle/.profile
fi

The ~oracle/.profile has the appropiate settings to start an Oracle database so it is always up-to-date for PHP, too. (If settings are changed, don't forget to restart your webserver.) This way you just no need to worry what to include or define for PHP.

I spent several hours tracking down error ORA 24374, which would result from only *SOME* of my select statements. This error would be caused if I made a query that would return any non-numerical value. I am running an Apache 1.3.x webserver and PHP 4.2.1.

The fix is to add entries in your httpd.conf file that would export your environment settings. I added these three lines and everything worked like a charm!
SetEnv ORACLE_HOME /path/to/oracle/home
SetEnv ORA_NLS33 /path/to/oracle/home/ocommon/nls/admin/data
SetEnv NLS_LANG AMERICAN

Obviously, if your NLS_LANG is different, you should set it to whatever your NLS_LANG actually is. Ask your friendly DB admin for this information.

Hope this helps someone who treads down the path that I just followed!

For those of you who would like to install this extension on an RedHat/CentOS server. It is actually pretty simple.

Here is what you have to do:1) Download the following RPM from Oracle: oracle-instantclient11.2-basiclite-11.2.0.2.0.x86_64.rpm (Version number can be newer and check if you need the 64bit version or not). And then install it on the server.

2) yum install php-oci8

3) And as the last step you edit /etc/sysconfig/httpd and write the following line at the end: export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib/ (Attention: Path changes depending on the version you have downloaded from the Oracle website.)

I was experiencing issues with Unicode characters being saved incorrectly to my ORA 10 DB. Issue was tracked to not having a NLS_LANG environment variable specified - set this correctly in the Apache environment and the issue was resolved.

After installing the Oracle Instant Client and adding it to the "PATH" Environment Variable, be sure that you also add "Read & Execute" privileges to the Oracle Instant Client directory for the IIS user designated for the site. This is especially necessary if IIS has been hardened using the IIS Lockdown tool (http://technet.microsoft.com/en-us/library/dd450372(WS.10).aspx) as users must be explicitly granted permissions from the web.

Hi, I use Oracle Database 10g Express Edition Release
10.2.0.1.0 on a Linux workstation for dev purposes, along
with Apache 2 and PHP5. So far I have used it on Kubuntu 8.04.
To get things working on a recently installed notebook with openSUSE
11.0 was a bit more complicated. So I hope someone will be able to
benefit from our experiences. Here is our howto:

# Use the package manager to install the packages php5-pear and
php5-dev, if not installed yet.

Replace 20060613+lfs with whatever module directory has been setup for you in /usr/lib/php5

Create /etc/php5/conf.d/oci8.ini:

----

extension=oci8.so

----

Now run the php cmdline in verbose mode (php -v) and see if everything loaded. Fix it if it didn't.

You may need some env variables setup in your /etc/init.d/apache2 file to make everything work and actually execute queries, but a phpinfo() at this point should show your oci8 extension. See the php.net Oracle pages if you need help with the env variables.

I had a problem loading php_oci8.dll with php 5.2, Apache, and windows XP - a module not loaded error, on every apache restart.
I eventually found that I had to add the oracle instantclient library path to the %PATH% under SYSTEM and not under USER. Doing that, and then rebooting, fixed the error - as Apache is starting as a service (outside the user setup).

# Here's what it took to get it going for me on Red Hat on
# x86_32 w/ 10gr2 and php5.1.2
# I sincerely appreciate all of the other poster's notes.
# It was a combination of a few
# of them to get mine configured. My note should reflect this:

# install the instantclient basic and sdk like this
# note: the original poster had you install into a lib subdirectory,
# but when I tried this it couldn't find the sdk files. So I moved
# the files in lib into the parent directory as
# shown below. Actually I copied them, YMMV
mkdir -p /usr/lib/oracle/10.2.0.2/client
unzip -jd /usr/lib/oracle/10.2.0.2/client
instantclient-basic-linux-x86-32-10.2.0.2-20060331.zip
mkdir -p /usr/include/oracle/10.2.0.2/client
unzip -jd /usr/lib/oracle/10.2.0.2/client
instantclient-sdk-linux-x86-32-10.2.0.2-20060331.zip
ln -s /usr/lib/oracle/10.2.0.2/client/libclntsh.so.10.1
/usr/lib/oracle/10.2.0.2/client/libclntsh.so

# I had to do this, or the OCI8 would not compile when
# I ran make on PHP5.1.2 I did not do this originally when I
# had the files in the lib sudirectory (see my note above) so
# that may be the true issue.
export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.2/client:$LD_LIBRARY_PATH

# here's what it took to get it going for me on rhel4 on x86_64 w/ 10gr2 and php5.0.5
# hopefully this will save someone a little grief
# first you must install the 10.2 full client in /app/oracle/product/10.2.0/db_1
# follow all the instructions. This part will be a bitch.

1) put everything in one directory
2) unsetenv ORACLE_HOME
3) set the env vars LD_LIBRARY_PATH and SQLPATH and TNS_ADMIN(if you have it) to that directory.
4) use one of the other easy connection notations here

These env vars worked when put at the top of apachectl script as well.

To build you may have to fake it out with an ORACLE_HOME var, but unset it later. You may also have to fake out the build by putting header files where it is looking for them, e.g. in the rdbms/demo directory or some such other place.

When running though, make sure you have only the files required in only one directory.

Oracle has not put up a link to the 32bit solaris sqlplus--you have to guess it--it's there though:

For those trying to use the Oracle Instant Client 10g in a win32 environment, heres a nice easy howto. If you fully read the docs properly and understand what your reading you will be able to set it up, but if like me you want a quick easy fix, heres how I did it.

1. Download and install the Oracle Instant Client to where ever (lets say c:\ora\client )
2. Add your connect info, copy a previously created or provided tnsnames.ora file to the above directory.
3. Change Path in the Environment Variables area to add this directory to the path. ie. c:\ora\client;%SystemRoot%;<and so on>
4. Open regedit and add a Key called ORACLE to HKEY_LOCAL_MACHINE\SOFTWARE
5. To the ORACLE key add a string value called TNS_ADMIN and assign it the directory above (ie. c:\ora\client ) So you end up with KEY_LOCAL_MACHINE\SOFTWARE\ORACLE\TNS_ADMIN = c:\ora\client
6. Set php to use Oci8 extension and bobs your uncle
7. Reboot.

Option 7 was required as the oci8 extension or php wouldn't pick up the path change. Also my problem was how to use other programs like sqlplus without creating extra Environment Variables etc the TNS_ADMIN / tnsnames.ora part makes that simpler and allows you to call things the same as you would before.

PS: This should apply to all the Instant Clients. I haven't tried it with any others but 10g though.

If you get your connectivity working with putenv on ORACLE_SID and ORACLE_HOME, but you do not want to use putenv because you want safemode on. You will need to pass these from your environment variables. Somehow setenv in httpd.conf did not do the trick for me... the values are set but the connectivity does not work. Then you will need to set the environment in your /etc/init.d/apachectl or /etc/profile and use a "PassEnv ORACLE_HOME ORACLE_SID" directive in httpd.conf so that these variables are picked up by php.

However, when you suexec in Apache 2.0, the server will only allow you to pass a given set of variables which are defined in the apache source code in the file apache-dir/support/suexec.c

In order to pass ORACLE_SID and ORACLE_HOME to PHP you need to add these to that file. The relevant changed piece of code where I added "ORACLE_" looks something like this:

Now you can use your ocli* functions, or better yet, use PEAR::DB functions which was my ultimate goal, with PEAR::DB you can forget about declaring ORACLE_HOME, ORACLE_SID and all that kind of things. Just use:

I had a little problem with ocilogon but only with RedHat 8.0. It always returned some kind of error during connection like 'OCISessionBegin - ... invalid character', or 'OCISessionBegin - ... missing or invalid option in ...'

I have finally found what is this problem! You have to change your LANG enviroment variable disabling UTF-8. Example: LANG=en_US.UTF-8 should become LANG=en_US.

I was first getting "...wrong ELF class: ELFCLASS64.."
while doing a ./configure with the --with-oci8 and --with-oracle parameters.

After some unsuccessfull searched I renamed the $ORACLE_HOME/lib to $ORACLE_HOME/lib.org and then renamed the
$ORACLE_HOME/lib32 to $ORACLE_HOME/lib

Thereafter it went passed this config, but now failed on
not being able to find a libwtc9.so file which was in the
$ORACLE_HOME/lib directory (this message was displayed in the debug.log in the php source directory).

After setting the Environment variable:
LD_LIBRARY_PATH=$ORACLE_HOME/lib
I was able to compile without any errors and 'make' and 'make install' ran smoothly.

I only had to add the php type in the httpd.conf (in your apache conf directory eg. /usr/local/apache/conf)..
AddType application/x-httpd-php .php
to get the php to work again...

I had to then reverse the $ORACLE_HOME/lib swop on top since php was now having problems with the 32 bit version of the library...so switched it back to 64 and my php script worked....

Problem: Regular and Remote authentication does not work using Windows 2000 + PHP and Oracle 8i, 9i.

Secondary Issue if using Oracle 9.2.0.1
When using Oracle 9.2.0.1 the Error structure returned by Oracle is different than expected by PHP. As a result there will be no legible error message other than the following;
Warning: _oci_open_server: in ...

Using Oracle 9.0.1.1 the error message returned is any of the following depending on your situation;

Warning: _oci_open_server: ORA-12638: Credential retrieval failed in ...
Warning: _oci_open_server: ORA-12154: TNS:could not resolve service name in ...
Warning: _oci_open_server: ORA-12505: TNS:listener could not resolve SID given in connect descriptor in ...

Resolution:
In order to get this to work properly you need to do the following;
In reference to ORA-12638: Credential retrieval failed in ...
you need to edit your sqlnet.ora file and change the
SQLNET.AUTHENTICATION_SERVICES = (NTS) to
SQLNET.AUTHENTICATION_SERVICES = (NONE)
The reason is that using NTS validation on a Windows 2000 machine essentially means Kerberos.
Using (NONE) will tell oracle not to expect kerberos "Credentials" as a means of validation. In turn it will use the oracle authentication for a database user.

In reference to ORA-12154 and ORA-12505 you need to do the following;
In your php code you are using to connect you need to copy the section in tnsnames.ora
into a variable.
For example;
<?php
putenv("ORACLE_SID=TESTDB");
//putenv("ORACLE_HOME=/oracle/ora90");
//putenv("TNS_ADMIN=/oracle/ora90/network/admin");
$username = "scott";
$passwd = "tiger";
$db="(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=yourTargetMachine)(PORT=1521)
)
)
(CONNECT_DATA=(SERVICE_NAME=TESTDB))
)";
$conn = OCILogon($username,$passwd,$db);
if (!$conn)
{
echo "Connection failed";
echo "Error Message: [" . OCIError($conn) . "]";
exit;
}
else
{
echo "Connected!";
}
...
?>
I left the ORACLE_HOME and TNS_ADMIN putenv lines commented out and your need for them depends on which web server you are using. If you are using Apache, you may need both.
If you are using Microsoft IIS you may need ORACLE_HOME. Putting it in can't hurt and it appears PHP may read them if they are there but either way you should be working at this
point.

- Make sure you have this use flags set: "dba cli pcre xml zlib oci8-instant-client"
- Unmask PHP (5.1.1) by placing "dev-lang/php ~x86" in /etc/portage/package.keywords
- Unmask oracle-instantclient-basic (10.2.0.1-r1) by placing "dev-db/oracle-instantclient-basic ~x86"
- Download oracle files from "http://otn.oracle.com/software/tech/ oci/instantclient/htdocs/linuxsoft.html" (You have to make an account and login, in order to download the packages:

- Place the downloaded packages in "/usr/portage/distfiles"
- "emerge apache dev-lang/php5" (If you done right, the build for the instantclient will be selected automaticly.
- Configure your "/etc/conf.d/apache2" to make sure you have "-D PHP5" in your "APACHE_OPTS"

If you want the change NLS_LANG (e.g.: NLS_LANG="FRENCH_FRANCE.WE8ISO8859P1") don't forget to also set LC_ALL and LANG (e.g.: LC_ALL=french and LANG=french) else you'll have a ORA-01756 when you try to call ocilogon.

I realized that PHP is a 32-bit application and that all 3rd-party libraries need to be 32-bit as well. You need to download the 32-bit version of Instant Client (basic + sdk), even if you are running the 64-bit Solaris OS.

ReCompiling PHP4 to have oracle 8 support (oci8) on Debian Linux, using the Oracle 10g client libraries. Log in as root.

PACKAGES REQUIRED:
php4-dev
php4 (source files)
php4 module (might not be required, but it's what i had installed at the time)

OTHER PACKAGE REQUIREMENTS:
Oracle Client Libraries (i used Oracle 10g Server, but you should be able to use, as has been previously said, any set of the oracle client libraries from 8i onwards).
* make sure this is installed before recompiling php4.

ENVIRONMENT REQUIREMENTS:
- export ORACLE_HOME=[where u installed the oracle client]
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
- export LD_PRELOAD=libclntsh.so.10.1 (the version number at the end will correspond to the oracle version you previously installed. in my case, 10g is 10.1).
- vi /etc/ld.so.conf and add $ORACLE_HOME/lib to the list of paths.
then * run ldconfig to reload those changes to the system * (p.s. make sure it's the full path, and not using any environment variables. e.g. /u01/app/oracle/product/10gRDBMS is my ORACLE_HOME).

- vi debian/rules
these are the default compilation rules for php4. Find section labeled COMMON_CONFIG = [...] and add --with-oci8 (it should be near the top of the file).

- debchange -i (allows you to edit the change log for the versions of php. btw - you should be in the php4 source code directory). give the version id something obviously unique. don't forget to add a comment.

when all is in readyness, then you should be able to go debian/rules binary to build the debian packages required.
the deb packages are built into the /usr/src directory. and depending on the default compilation options u choose, there should be a few. find the deb package that corresponds to the main php4 module (php4_4.3.8-4.mark.1_i386.deb for me), and run dpkg -i [package name] to install it.

IF YOU GET... :
if you get an error saying something about apache cannot load libclntsh.so.10.1, file not found, check the environment variables, for both the user, and in /etc/init.d/apache and also check ld.so.conf to make sure the $ORACLE_HOME/lib path is in there, and has been reloaded (with ldconfig).

editing ld.so.conf was the part that finally got it working for me.
as you should be able to tell, the steps are pretty much the same as for all oracle versions 8i onwards, and all linux OS's. but with a few debian specific paths and commands thrown in.

Having the gcc compilier build php against oracle 32 bit libraries was the key, but without setting LDFLAGS the compiler defaults to using the 64-bit oracle libraries which cause the famous
"...wrong ELF class: ELFCLASS64.." on startup.

The only diffenece here was I didn't have to do play musical directories for it to work. The below post was instrumental in helping me to get this fixed. Thanks to "lore_giver at lycos dot co dot uk"

When using PHP4 in CGI-mode with Windows NT or Windows 2000 with IIS or Apache, make sure that the TNSNAMES.ORA and the SQLNET.ORA do not contain DOS/Windows CR/LF line endings.<br> Instead, they must have UNIX (only LF) endings. Otherwise, you will get an ORA-12154 error (TNS cannot resolve service name) when connecting to a remote database.<br>
This all does not matter if you use the ISAPI mode.

It is well known that the Oracle Instant Client 11g libraries conflict with the OpenLDAP ones.

If features of the 11g client libraries are vital (e.g. needing SQLNET timeouts to work and/or needing to get Oracle service names from directory servers via LDAP - both required in my organisation) then in order to achieve a working oci8 and OpenLDAP setup it is necessary to preload the instant client library in the Apache startup script - e.g.:

The Oracle error "ORA-03106: fatal two-task communication protocol error" is indicative of not having NLS_LANG set.

In my case, I had a successfully processing INSERT statement followed by a failing SELECT statement that was resulting in that ORA-03106 error. The successful INSERT implied that all Oracle environment settings were fine. Ultimately we found that the NLS_LANG was not set, and I have to assume that only the SELECT of data back from the database actually _needed_ it, and therefore it was the SELECT statement that triggered the failure. Though, that is all speculation.

It was really hard to find, but I got there by choosing Downloads > Oracle Database 11g Release 2 then clicked the "See All" link on the far right of the Microsoft Windows (32-bit) download links under (11.2.0.1.0)

On this page the second option down is a link to download just the client libraries.

I unzipped it, and ran setup.exe

I chose Runtime, I couldn't get InstantClient to work.

I used the defaults for Oracle Base and Oracle Home, make sure to write these down you need them.
Oracle Base: "D:/app/Administrator"
Oracle Home: "D:/app/Administrator/product/11.2.0/client_1"

I chose just English as the language.

Next'd through the rest of the installer... The nice thing about this full install is that it sets the Windows Path variable for you, and it has the required library files.

In my php.ini file located in /xampp/php/php.ini
Remove the semicolon from the front of the line: extension=php_oci8_11g.dll

In my apache httpd.conf file in /xampp/apache/conf/httpd.conf

Add the following SetEnv lines to the end of the <Directory "C:/xampp/htdocs"> This is where you use the oracle base and home paths you wrote down earlier while installing the oracle client ;) This is what mine looks like without all the comments.