php7没有oci8,需要安装配置,php7安装oci8扩展的方法是:1、下载并安装“oracle-instantclient19.5-basic-19.5.0.0.0-1.x86_64.rpm”;2、添加环境变量;3、在php官网直接搜oci8;4、通过“pecl install oci8”命令安装oci8即可。

本教程操作环境:centos7系统、PHP7版、Dell G3电脑。

php7没有php oci8吗?

需要安装配置。

php7 安装扩展-oci8 步骤方法:

1. 基础环境

环境:centos7 PHP 7.2.24

2. oracle客户端

2.1 官方地址

https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

使用的最新的版本-Version 19.5.0.0.0 ,两个都必须安装,devel版本就是SDK

oracle-instantclient19.5-basic-19.5.0.0.0-1.x86_64.rpm 
oracle-instantclient19.5-devel-19.5.0.0.0-1.x86_64.rpm

2.2 安装

rpm -ivh oracle-instantclient19.5-basic-19.5.0.0.0-1.x86_64.rpm 
rpm -ivh oracle-instantclient19.5-devel-19.5.0.0.0-1.x86_64.rpm

安装完成后默认路径–/usr/lib/oracle/19.5/client64,我没有添加环境变量,如果有需要,根据自己配置添加。

vim /etc/profile
source /etc/profile

3. oci8扩展

网上文章安装比较混乱,去php官网直接搜oci8就会出现结果;

1ee421fba713f9900291fc9f0858a42.jpg

3.1 安装

我采取的第一种方法,pecl install oci8;安装过程总会出现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/19.5/client64/lib

f503ec9191de1ef279b4a7131d48d67.jpg

3.2 检查

安装完成后使用–php -m ,检查是否安装成功,进入目录–/usr/lib64/php/modules ,查看是否存在–oci8.so ;

重启之后如果不成功,可以在 /etc/php.ini文件中,添加扩展—extension=oci8.so 。

3.3 重启php-fpm


php7没有php oci8吗