Centos下PHP7.1打开Oracle扩展
背景
最近因为项目研究了一下PHP集成Oracle,虽然这个组合很奇葩,但万一用到请勿采坑~
环境
- CentOS Linux release 7.3.1611 (Core)
- PHP7.1.1
安装oracle组件
下载 http://www.oracle.com/technet...
oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
PS: 两个都必须安装,devel版本就是SDK
安装
# rpm -i oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm # rpm -i oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm
安装成功会生成如下目录,64位系统必须软连接成旧版(否则编译报版本不支持的错,应该是历史问题,坑1)
# ln /usr/lib/oracle/12.2 /usr/lib/oracle/10.2.0.1 # ln /usr/include/oracle/12.2 /usr/include/oracle/10.2.0.1
添加环境变量
# vi etc/profile
加入
export ORACLE_HOME=/usr/lib/oracle/11.2/client64/ export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64:$LD_LIBRARY_PATH export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
生效
# source /etc/profile
编译安装oci8和pdo_oci
下载最新的包
oci8-2.1.8.tgz和PDO_OCI-1.0.tgz
编译安装oci8
# tar -zxf oci8-2.1.8.tgz # cd oci8-2.1.8 # phpize # ./configure --with-php-config=/usr/local/php/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/12.2/client64/lib # make # make install
生成oci8.so即成功
编译安装pdo_oci
# tar -zxf PDO_OCI-1.0.tgz # cd PDO_OCI-1.0 # phpize # ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-oci=instantclient,/usr,10.2.0.1 # make # make install
生成pdo_oci.so即成功
打开PHP扩展
具体方式根据PHP环境而定,我的环境不需要改变so文件路径,使用生成的默认路径即可,只需要添加Additional .ini files到/usr/local/php/etc/php.d/,重启生效
确认生效状态
# php -m | grep -e oci8 -e PDO_OCI oci8 PDO_OCI
大功告成
PS
由于编译安装下载的pdo_oci总是报错(坑2),于是到php.net下载了对应版本的php(比如:http://us1.php.net/get/php-7....),拷贝ext目录下的pdo_oci编译安装,步骤同上。
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23