InstallationConfiguring PHP with OCI8Review the previous Requirements section before configuring 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 19 libraries, then PHP should also be deployed and run with Oracle 19 libraries. PHP applications can connect to other versions of Oracle Database, since Oracle has client-server cross-version compatibility. Installing OCI8 from PECL Using the pecl CommandThe OCI8 extension can be added to an existing PHP installation by using the » PECL repository.
Installing OCI8 from PECL Using phpize
To install OCI8 on an existing PHP installation when
the
Installing OCI8 as a Shared Extension when Building PHP
If you are building PHP from source code, the
configuration Configure OCI8 using one of the following configure options.
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 when Building PHPIf you are building PHP from source code, you can configure PHP to include OCI8 as a static extension using one of the following configure options.
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 on Windows
The OCI8 extension can be added to an existing PHP installation by using the
DLLs from » PECL repository or
the libraries in your PHP installation's
With Oracle 12c (or later) libraries, uncomment one of
the php.ini lines If using Instant Client, set the system PATH environment variable to the Oracle library directory. Setting the Oracle EnvironmentBefore 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.
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 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.
TWO_TASK , ORA_TZFILE , and the
various Oracle globalization settings
like NLS* and the ORA_NLS_*
variables.
TroubleshootingThe 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.
|