一紧武、安裝oracle客戶端
1. 首先去oracle官網(wǎng)下載三個(gè)客戶端的包
oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
官網(wǎng)有個(gè)問題道偷,下載速速很慢吩谦,不能翻墻或者下載慢的可以去360云盤下載
https://yunpan.#/surl_ycn8isDGr7U (提取碼:020b)
2. 執(zhí)行安裝命令
rpm -ivh oracle-instantclient12.2-*
3. 添加環(huán)境變量
[root@localhost ~]# vim /etc/profile
## 在尾部增加如下內(nèi)容
export ORACLE_HOME=/usr/lib/oracle/12.2/client64
export ORACLE_BASE=/usr/lib/oracle/12.2
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
保存退出后執(zhí)行:source /etc/profile
二术徊、安裝oci8的php擴(kuò)展
1. 方法一:pecl安裝
pecl install oci8
.....
期間會(huì)出現(xiàn):
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] :
輸入剛剛安裝的路徑并回車,如下所示:
instantclient,/usr/lib/oracle/12.2/client64/lib
....
驗(yàn)證是否安裝成功
[root@localhost src]# php -m | grep oci8
oci8
重啟php-fpm服務(wù)
/etc/init.d/php-fpm restart
2. 方法二:編譯安裝
分別執(zhí)行如下命令:
[root@localhost src]# wget http://pecl.php.net/get/oci8-2.1.8.tgz
[root@localhost src]# tar xzvf oci8-2.1.8.tgz
[root@localhost src]# cd oci8-2.1.8
[root@localhost oci8-2.1.8]# phpize
[root@localhost oci8-2.1.8]# ./configure --with-oci8=instantclient,/usr/lib/oracle/12.2/client64/lib
[root@localhost oci8-2.1.8]# make && make install
# php.ini中增加擴(kuò)展引入
[root@localhost oci8-2.1.8]# vim /etc/php.d/oci8.ini
extension=oci8.so
## 驗(yàn)證是否成功
[root@localhost oci8-2.1.8]# php -m | grep oci8
oci8
至此挪蹭,oci8的php擴(kuò)展安裝成功亭饵,祝大家使用oracle愉快!