linux安装oci客户端及php的oci8扩展安装

linux安装oci客户端及php的oci8扩展安装

    • oci客户端安装
    • 安装oci8扩展

oci客户端安装

  1. 下载程序包
    oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
    oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm
    oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm
    //网盘密码:r6e6
  2. 进行安装
$  yum install oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
$  yum install oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm
$  yum install oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm
$	echo "/usr/lib/oracle/18.3/client64/lib/" > /etc/ld.so.conf.d/oracle_client.conf
$  /sbin/ldconfig
$  CFLAGS="-I/usr/include/oracle/18.3/client64"
$  CXXFLAGS="-I/usr/include/oracle/18.3/client64/"
  1. 连接数据库
$ /usr/lib/oracle/18.3/client64/bin/sqlplus usr/pwd@//host:port/sid
SQL*Plus: Release 18.0.0.0.0 - Production on Fri Sep 21 20:16:22 2018
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL>

上述如果可以用sqlplus连接Oracle就基本表示安装成功了

安装oci8扩展

  1. 安装
$  wget http://pecl.php.net/get/oci8-2.0.10.tgz
$  tar -vxf oci8-2.0.10.tgz
$  cd oci8-2.0.10
$  phpize
$  ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/18.3/client64/lib --with-php-config=/usr/local/php/bin/php-config
$  make
$  make test
$  make install

现在php中就会生成oci8.so (我的PHP版本是5.6.24)
根据 make install 执行时显示的具体路径在 php.ini 中添加 如下代码

[oci8]
extension = "/usr/local/php-5.6.24/lib/php/extensions/no-debug-non-zts-20131226/oci8.so"
  1. 查看安装情况
$  php -m 

显示信息中包括oci8表示安装成功
现在就可以在php文件中进行oracle操作了!

你可能感兴趣的:(linux安装oci客户端及php的oci8扩展安装)