The PHP "./configure --with-oci8" Option in Detail
By cj on Mar 12, 2009
When PHP is built from source code on Linux, the typical build steps are:
tar -xjf php-5.2.9.tar.bz2
The "configure" stage creates the appropriate makefile to build all the extensions you want. Specify the --help option to list all the many build configurations available.
To build PHP with the OCI8 extension, use the --with-oci8 option:
./configure --with-oci8 ...
OCI8 needs to link with Oracle libraries which handle communication to the database. The main choice when building the OCI8 extension depends on what Oracle libraries you have installed.
PHP OCI8 can be built using libraries from a full Oracle Database (or Database "Client") install, created from running the GUI installer. This is often referred to as an "ORACLE_HOME" install, since an environment variable of that name is set to the installed Oracle software directory.
Alternatively PHP OCI8 can be built using the free Oracle Instant Client, installed from zip files or RPMs. If you are building with Oracle Instant Client you almost certainly should not have the ORACLE_HOME environment variable set. Only set ORACLE_HOME if you have a full Oracle install.
Another dimension to the install is that PHP extensions can be statically compiled into the PHP executable(s), or built as shared binaries. If OCI8 is built as a shared library it is loaded into PHP as a result of setting the php.ini option "extension=oci8.so". Building shared extensions like this makes it easy to upgrade one extension without affecting the rest of PHP.
The list below describes how to use the --with-oci8 option.
Looks for Oracle Database libraries in $ORACLE_HOME, which must previously have been set.
Links the oci8 extension statically into the php executable(s)
Same as #1, but uses the specified path instead of de-referencing $ORACLE_HOME.
Same as #1, but creates an oci8.so shared library.
Like #2 and #3 combined: uses the specified Oracle Database libraries and creates a shared oci8.so extension.
Looks for Oracle Instant Client RPMs and uses the most recent version installed.
Links the oci8 extension statically into the php executable(s).
Like #5, but uses the Instant Client in the specified directory.
Like #5, but builds a shared oci8.so extension.
Like #6 and #7 combined: uses the specified Instant Client and creates a shared oci8.so extension.
In a future blog post I will talk about the options for installing from PECL, which is useful for adding OCI8 to an existing PHP install.