
我正在嘗試在 Red Hat 7 (PHP 5.6.x.) 上安裝 OCI8 擴充功能。 我花了至少兩天的時間試圖解決這個問題,包括結合 SuperUser 和 StackOverflow。到目前為止,所有答案都沒有解決問題。
我已將 Oracle Instant Client 安裝在:
/usr/lib/oracle/12.1/client64/lib/
當我運行以下命令:
pecl install oci8-2.0.10 --with-oci8=instantclient,/usr/lib/oracle/12.1/client64/lib/
它要求我提供 ORACLE_HOME 的路徑。我確認這已經定義了,所以我按 Enter 繼續。一旦我這樣做了,它就會運行 make 命令並出現錯誤:
/bin/sh /var/tmp/pear-build-rootb3mVn8/oci8-2.0.10/libtool --mode=compile cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootb3mVn8/oci8-2.0.10/include -I/var/tmp/pear-build-rootb3mVn8/oci8-2.0.10/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/home/oracle/oracle/product/rdbms/public -I/home/oracle/oracle/product/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8.c -o oci8.lo
libtool: compile: cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-rootb3mVn8/oci8-2.0.10/include -I/var/tmp/pear-build-rootb3mVn8/oci8-2.0.10/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/home/oracle/oracle/product/rdbms/public -I/home/oracle/oracle/product/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8.c -fPIC -DPIC -o .libs/oci8.o
In file included from /var/tmp/oci8/oci8.c:48:0:
/var/tmp/oci8/php_oci8_int.h:60:17: fatal error: oci.h: No such file or directory
#include <oci.h>
^
compilation terminated.
make: *** [oci8.lo] Error 1
ERROR: `make' failed
我知道它找不到 oci.h 檔案。所以我想,如果我向它提供 Oracle Instant Client 的位置,它就會跳過該錯誤。因此,在請求 ORACLE_HOME 環境變數的上一個命令中,我為其提供以下內容:
checking Oracle ORACLE_HOME install directory... /usr/lib/oracle/12.1/client64/lib/
checking ORACLE_HOME library validity... configure: error: Expected an ORACLE_HOME top level directory but /usr/lib/oracle/12.1/client64/lib/ appears to be an Instant Client directory. Try --with-oci8=instantclient,/usr/lib/oracle/12.1/client64/lib/
ERROR: `/var/tmp/oci8/configure --with-oci8=/usr/lib/oracle/12.1/client64/lib/' failed
我無法弄清楚它為什麼失敗。我聽說需要安裝SDK,但據我所知,當我安裝即時客戶端時,我也安裝了SDK。
任何幫助將非常感激。謝謝!
答案1
我遇到了完全相同的問題,只有一個差異,在我的例子中是 php54。我確實認為/希望我的解決方案也適合您:
echo "instantclient,/usr/lib/oracle/12.1/client64/lib"|pecl install oci8-2.0.10
安裝oci驅動程式沒有任何問題。就我而言,由於預設的 php 版本是 5.3,因此我使用了 rh 為 5.4 提供的軟體包,並且必須在啟動 pecl 進行 oci 安裝之前獲取 /opt/rh/php54/enable 的源代碼。我希望這有幫助