安裝instant client
首先,是從https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html下載相應(yīng)的數(shù)據(jù)庫(kù)版本對(duì)應(yīng)的basic和devel的rpm包或zip壓縮包。我這里選擇rpm包。然后安裝:
rpm -Uvh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpmrpm -Uvh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
這樣,instant client工具已經(jīng)安裝好了。接下來是PHP的擴(kuò)展oci8。
安裝oci8擴(kuò)展
關(guān)于oci8的安裝方法,在PHP官方文檔中有詳細(xì)的介紹,在線地址http://php.net/manual/en/oci8.installation.php。我這里選用pecl安裝。直接運(yùn)行命令:
pecl install oci8
注意,如果你和我一樣使用的也是PHP7.0以上的版本,那么使用上面的命令。如果是其他版本,可以看到pecl的oci8頁(yè)面有相關(guān)說明:
Use pecl install oci8-2.0.12 to installfor PHP 5.2 - PHP 5.6. Use pecl install oci8-1.4.10 to install forPHP 4.3.9 - PHP 5.1
在運(yùn)行安裝命令后,會(huì)提示輸入instant client路徑,原文提示為:
Please provide the path to the ORACLE_HOME directory.Use instantclient,/path/to/instant/client/lib if you re compilingwith Oracle Instant Client [autodetect] :
默認(rèn)路徑為/usr/lib/oracle/11.2/client64/lib。注意,要在前面加上instantclient,完整輸入為:
instantclient,/usr/lib/oracle/11.2/client64/lib
我第一次安裝的時(shí)候,沒有仔細(xì)閱讀,只看到最后的autodetect便直接回車了,導(dǎo)致后面測(cè)試連接數(shù)據(jù)庫(kù)失敗。等待安裝好后,還需要最后一步,便是在php.ini中加入配置extension=oci8.so或另起一個(gè).ini文件,重啟php-fpm:
service php-fpm restart
現(xiàn)在,你便可以連接Oracle數(shù)據(jù)庫(kù)了,本地開發(fā)環(huán)境也搭建好了。
以上就是PHP+Oracle本地開發(fā)環(huán)境搭建的詳細(xì)內(nèi)容,PHP教程
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。
新聞熱點(diǎn)
疑難解答
圖片精選