环境是lnmp.org一键安装包配置,oci8扩展包下载见底部

安装Oracle客户端

rpm -ivh oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.1-jdbc-12.1.0.2.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

安装OCI8扩展

  1. 安装扩展

    tar zxvf oci8-2.1.3.tgz
    cd oci8-2.1.3
    phpize
    ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client64/lib --with-php-config=/usr/local/php/bin/php-config
    make && make install
  2. 修改php.ini配置

    vim /usr/local/php/etc/php.ini

    开启扩展

    extension=oci8.so

安装PDO_OCI扩展

  1. 环境配置
    a. vi /etc/ld.so.conf加入下面行

    /usr/lib/oracle/12.1/client64/lib/

    b. 64位系统需要创建32位的软链接(这里可能是一个遗留bug,不然后面编译会出问题)

    ln -s /usr/lib/oracle/12.1/client64 /usr/lib/oracle/12.1/client  
    ln -s /usr/include/oracle/12.1/client64 /usr/include/oracle/12.1/client  

    c. 环境变量加入如下内容vi etc/profile

    export ORACLE_HOME=/usr/lib/oracle/12.1/client64/  
    export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64:$LD_LIBRARY_PATH  
    export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"

    环境变量立即生效source /etc/profile

    d. 防止pdo_oci对oracle12支持不足(pdo_oci可能不支持oracle12g,需要做个软链接成作为oracle10版本才能编译过去): 【装10版本的 没试过】

    ln -s /usr/include/oracle/12.1 /usr/include/oracle/10.2.0.1  
    ln -s /usr/lib/oracle/12.1 /usr/lib/oracle/10.2.0.1 
  2. 安装扩展
    进入对应扩展包php_oci

    /usr/local/php/bin/phpize
    ./configure --with-pdo-oci=instantclient,/usr,10.2.0.1 --with-php-config=/usr/local/php/bin/php-config
    make && make install
  3. 修改php.ini配置

    vim /usr/local/php/etc/php.ini

    开启扩展

    extension=pdo_oci.so

重启服务

service nginx restart
service php-fpm restart

文件下载(可加群获取)

  1. oci8-2.1.3.tgz
  2. oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
  3. oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
  4. oracle-instantclient12.1-jdbc-12.1.0.2.0-1.x86_64.rpm
  5. oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm

联系我

如果你还是不明白的话,或者本文章内资源下载不了,可以联系我,或者是加我的QQ群(群内有资源提供下载),大家可以多多交流:

qqqq


klinson
141 声望12 粉丝