1、安装oracle客户端
rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
检查是否安装成功,安装成功时显示下图
rpm -qa | grep oracle
2、修改 /etc/ld.so.conf,添加下方代码
/usr/lib/oracle/12.2/client64/lib/
3、添加软连接
ln -s /usr/lib/oracle/12.2/client64 /usr/lib/oracle/12.2/client
ln -s /usr/include/oracle/12.2/client64 /usr/include/oracle/12.2/client
4、添加环境变量 /etc/profile
export ORACLE_HOME=/usr/lib/oracle/12.2/client64/
export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64:$LD_LIBRARY_PATH
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
5、执行 source /etc/profile 使环境变量生效
6、安装 oci8-2.2.0.tgz,根据PHP版本下载
wget https://pecl.php.net/get/oci8-2.2.0.tgz
tar -zxvf oci8-2.2.0.tgz
cd oci8-2.2.0/
phpize
./configure -with-oci8=shared,instantclient,/usr/lib/oracle/12.2/client64/lib
make && make install
echo extension = oci8 >> /etc/php.d/30-oci8.ini # ini 注意添加扩展方式可能会不同
#php -m 出现错误时安装
#yum install libnsl
# 重启php-fpm
systemctl restart php-fpm
原创文章,作者:admin,如若转载,请注明出处:https://ntib.cn/434.html