windows下PHP的oci和pdo_oci擴充套件安裝
配置環境:
- windows7
- PHP Version 5.6.19
- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
安裝oci擴充套件
Configuring PHP with OCI8
Review the previous Requirements section before configuring OCI8.
To enable the OCI8 extension, configure PHP with the option –with-oci8 .
翻譯:開啟–with-oci8配置即可開啟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 should be set before any PHP process starts.
PHP should be run 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需要配置與連線的oracle資料庫相同版本或者更新版本的OCI擴充套件庫。……
Installing OCI8 on Windows
On Windows, uncomment the php.ini line extension=php_oci8.dll when using Oracle 10gR2 client libraries. Uncomment extension=php_oci8_11g.dll when using Oracle 11g client libraries. These two DLLs contain equivalent functionality and only one may be enabled at a time. 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.
翻譯:如果使用Instant Client,設定環境變數指向oralce目錄
根據PHP手冊得到配置步驟:
- 配置php.ini,開啟extension=php_oci8_12c.dll,如果PHP版本非文章中的版本,應該是php_oci8.dll或者php_oci8_11g.dll,這裡要根據你使用的oralce版本來選擇。dll檔案版本高的相容版本低的,版本低的無法相容版本高的。
- 安裝oralce Instant Client,下載連線。自己選擇環境版本,不要搞錯作業系統位數就行。
- 將自己下載的Instant Client,放到自己的軟體目錄裡。然後在環境變數的PATH裡面加入Instant Client的路徑。重啟電腦使環境變數生效。(不重啟也可,自行baidu)
- 測試連線oracle是否成功。
安裝pdo_oci擴充套件
如果你已經安裝OK了oci擴充套件,那麼僅需要將extension=php_pdo_oci.dll開啟即可。如果沒有則執行安裝oci擴充套件裡面2和3步驟。別忘了重啟WEB伺服器。