CentOS 7 PHP 7.3 安装 Oracle扩展

鉴于网上搜到的教程都比较陈旧且操作繁琐,特更新一篇新版的教程

本文在CentOS 7.6和PHP7.3.6上验证通过

 

1. 下载

oracle-instantclient19.3-basic-19.3.0.0.0-1.x86_64.rpm

oracle-instantclient19.3-devel-19.3.0.0.0-1.x86_64.rpm

oci8-2.2.0.tgz

以上三个包在Oracle官网都能下载到

 

2. 安装instantclient1

yum install oracle-instantclient19.3-basic-19.3.0.0.0-1.x86_64.rpm 
yum install oracle-instantclient19.3-devel-19.3.0.0.0-1.x86_64.rpm

将会安装到/usr/lib/oracle/19.3/client64目录

 

3. 编译安装oci8

tar zxvf oci8-2.2.0.tgz
cd oci8-2.2.0
phpize
./configure --with-oci8=instantclient,/usr/lib/oracle/19.3/client64/lib
make
sudo make install

如果php编译安装到/opt/php目录,扩展将会安装到/opt/php/lib/php/extensions/no-debug-non-zts-20180731/

 

4. 编译安装pdo_oci

PHP 7.3.6的源码包里已经附带了pdo_oci的源码,但要手动编译生成扩展

cd php-7.3.6/ext/pdo_oci/
phpize
./configure --with-pdo-oci=instantclient,/usr/lib/oracle/19.3/client64/lib
make
sudo make install

如果php编译安装到/opt/php目录,扩展将会安装到/opt/php/lib/php/extensions/no-debug-non-zts-20180731/

 

5. 加载oci8和pdo_oci模块

修改php.ini文件,增加或修改

extension=oci8.so
extension=pdo_oci

重启PHP-FPM服务,即可生效

你可能感兴趣的:(Php,CentOS,linux)