When PHP is built from source code on Linux, the typical build steps are:
tar -xjf php-5.2.9.tar.bz2 cd php-5.2.9 ./configure --with-your-desired-extensions make make test make install
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.
- --with-oci8
Looks for Oracle Database libraries in $ORACLE_HOME, which must previously have been set.
Links the oci8 extension statically into the php executable(s)
I just merged an enhancement that if $ORACLE_HOME is not set, will then look for the Instant Client RPM libraries. This patch will appear in PHP 5.3 and the future PECL OCI8 1.3.5.
- --with-oci8=/path/to/full/oracle/home
Same as #1, but uses the specified path instead of de-referencing $ORACLE_HOME.
- --with-oci8=shared
Same as #1, but creates an oci8.so shared library.
- --with-oci8=shared,/path/to/full/oracle/home
Like #2 and #3 combined: uses the specified Oracle Database libraries and creates a shared oci8.so extension.
- --with-oci8=instantclient
Looks for Oracle Instant Client RPMs and uses the most recent version installed.
Links the oci8 extension statically into the php executable(s).
- --with-oci8=instantclient,/path/to/instantclient/libs
Like #5, but uses the Instant Client in the specified directory.
- --with-oci8=shared,instantclient
Like #5, but builds a shared oci8.so extension.
- --with-oci8=shared,instantclient,/path/to/instantclient/libs
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.