Since last week, it has been plagued by a problem. The company installed the Oracle9i client on its computer and then connected to the Oracle database using Apache 2.2 + PHP 5. No matter how configured, OCI cannot be used.
(To use a 10 Gb Oracle client, you only need to Remove PHP. the annotation of INI php_oci8.dll will support oci8. The 10g client on my laptop has no problems at all. however, Oracle9i cannot be detached for 10 Gb for some other reasons)
I also found a lot of information on the Internet to study. some cool people on the internet gave this explanation.
PhP5 oci8 is not compatible with Oracle oci5.1.2 or above.
PHP is designed to rely on 10 because they think the latter is selected between the 8i compatibility mode and the instantclient that allows users to download 10.
This will cause problems.
That is to say, to enable PHP to support OCI to connect to the Oracle database, you must rely on the function library of Oracle client version 10 or later.
In addition, this solution is provided on the Oracle website.
Http://www.oracle.com/technology/global/cn/pub/notes/technote_php_instant.html Chinese Version
English http://www.oracle.com/technology/pub/notes/technote_php_instant.html
Download PHP binary compressed files (not the installer version) and Apache. Install them on the Windows System in the PHP manual. OTN's Open-Source Developer Center contains links to useful background materials, such as "installing Oracle, PHP, and Apache on Windows 2000/XP ", it introduces how to install the traditional and Complete Oracle 10GVersion (this version is not required for Instant Client ).
Check whether PHP is running normally before continuing the operation. Oracle Support is not enabled at this stage.
Download the Instant Client Basic Package for Windows from the Instant Client page of OTN. The size of the compressed file is about 30 mb.
Create a sub-directory (for example, c: \ instantclient10_1) and copy the following library from the compressed file:
- Oraociei10.dll
- Orannzsbb10.dll
- OCI. dll
The total size of these three files is about 80 Mb.
To use an earlier version of the "oracle" extension of PHP (Enabled with "extension = php_oracle.dll" in PHP. INI), copy ociw32.dll instead of OCI. dll.
Edit this environment and add c: \ instantclient10_1 to path (before other Oracle Directories ).
For example, on Windows 2000, clickStart> set> Control Panel> system> advanced> environment variable"To edit the path in the system Variable list.
If the tnsnames. ora file is used to define the Oracle Net service name, copy tnsnames. ora to c: \ instantclient10_1 and set the user environment variable tns_admin to c: \ instantclient10_1. You can also define the default service name in the local environment variable.
Set the required Oracle global language environment variables, such as nls_lang. If this parameter is not set, the default local environment is used. For more details, see the overview of Oracle PHP application globalization.
You do not need to set unnecessary Oracle variables, such as ORACLE_HOME and oracle_sid.
Edit PHP. ini and do not set the oci8 extension as a comment:
extension=php_oci8.dll
Set the extension_dir command to the complete PHP extension DLL path. In PHP 4, the DLL is located in the "extensions" subdirectory of the PHP software. In PHP 5, they are located in "Ext.
Restart Apache.
To check whether extensions are configured, create a simple PHP script where the Web server can read.
<?php
phpinfo();
?>
Use the "http: //" URL to load the script to the browser. The browser page should contain an "oci8" section showing "oci8 support enabled.
It may be a little dull. To tell the truth, I completely followed the above steps, but it still failed, and the environment variables are not supported. Using phpinfo (), there is still no oci8 part.
Open the command prompt, go to the PHP installation directory, and enter PHP-V for verification.
Unable to locate program Input Point ocistmtprepare2 on Dynamic Link Library OCI. dll
I cannot understand why I still cannot locate the environment variable on OCI. dll? Therefore, copy the three DLL files in step 3 to the PHP installation directory, and input the PHP-V file again without prompting the error.
PHP script phpinfo () verification still does not support oci8. well, maybe it's still a problem with environment variable configuration.
So I copied the three DLL files in step 3 to the bin directory of Apache again. Restart Apache and use the PHP script for verification again ~
Delete the three DLL files in the PHP installation directory, restart Apache, and use the PHP script for another verification. oci8 support is still supported.
After a week of troubleshooting, I reviewed and summarized the configuration steps as follows:
Prerequisites: Apache 2.2 + PhP 5.2.9 has been configured with OK
Step 1: Download the Instant Client Basic Package for windows on the Instant Client page, decompress and copy the package
Oraociei10.dll
Orannzsbb10.dll
OCI. dllThe three DLL files are stored in the Apache bin directory.
Step 2: remove the comments before php_oci8.dll in the PHP. ini file and enable PHP to add the OCI Extension function. Restart Apache.
Step 3: Write a PHP script
<? PHP
Phpinfo ();
?>
Use the "http: //" URL to load the script to the browser. The browser page should contain an "oci8" section showing "oci8 support enabled.
Step 4: Although oci8 support is enabled, to make the client's nls_lang match the nls_lang in the database, otherwise there will be another error ORA-12705: Invalid or unknown NLS parameter value specified
Modify nls_lang on the client: Open the Registry HKEY_LOCAL_MACHINE \ SOFTWARE \ oracle and find the nls_lang key value. The original value is Na, which is the same as that on the server.
In theory, the method for setting environment variables is correct, but it does not apply to my machine. The reason is unknown. Here we provide such a method. For more information, see.