安裝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.rpm
rpm -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 install
for PHP 5.2 - PHP 5.6. Use 'pecl install oci8-1.4.10' to install for
PHP 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 compiling
with 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)境也搭建好了。
標(biāo)簽:甘肅 十堰 遼陽(yáng) 九江 梅河口 韶關(guān) 昭通 涼山
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PHP+Oracle本地開發(fā)環(huán)境搭建方法詳解》,本文關(guān)鍵詞 PHP+Oracle,本地,開發(fā),環(huán)境,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。