无限星辰工作室-客户无限互联网动力之源

标题: PHP 连接 oracle 报错:Oracle libraries and NLS data 解决方案 [打印本页]

作者: crx349    时间: 2020-3-21 03:03
标题: PHP 连接 oracle 报错:Oracle libraries and NLS data 解决方案
PHP(Thinkphp5)使用PDO_OCI连接Oracle 报错:
  1. SQLSTATE[HY000]: OCIEnvNlsCreate: Check the character set is valid and that PHP has access to Oracle libraries and NLS data
复制代码

解决方法:
php-fpm.conf 底部加上
  1. env[LD_LIBRARY_PATH] = /usr/lib/oracle/19.6/client64/lib
  2. env[ORACLE_HOME] = /usr/lib/oracle/19.6/client64/lib
复制代码

指向oracle安装目录
重启php 搞定

附录:
pdo_oci安装流程

centos 7下

1.先安装oracle客户端 oracle客户端rpm包,https://www.oracle.com/database/ ... 6-64-downloads.html 下载

  1. rpm -ivh oracle-instantclient19.6-basic-19.6.0.0.0-1.x86_64.rpm
  2. rpm -ivh oracle-instantclient19.6-devel-19.6.0.0.0-1.x86_64.rpm
  3. rpm -ivh oracle-instantclient19.6-sqlplus-19.6.0.0.0-1.x86_64.rpm
复制代码

软连接
  1. ln -s /usr/include/oracle/19.6 /usr/include/oracle/10.2.0.1
  2. ln -s /usr/lib/oracle/19.6 /usr/lib/oracle/10.2.0.1
复制代码

2.pdo_oci php源码包编译

  1. cd ext/pdo_oci
  2. /www/server/php/56/bin/phpize
  3. ./configure --with-php-config=/www/server/php/56/bin/php-config --with-pdo-oci=instantclient,/usr,10.2.0.1
  4. make && make install
复制代码

3.oci8 php源码包编译

  1. cd ext/oci8
  2. /www/server/php/56/bin/phpize
  3. ./configure --with-php-config=/www/server/php/56/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/19.6/client64/lib
  4. make && make install
复制代码

php.ini添加

  1. extension=oci8.so
  2. extension=pdo_oci.so
复制代码

重启php 看看phpinfo





欢迎光临 无限星辰工作室-客户无限互联网动力之源 (https://xmspace.net/) Powered by Discuz! X3.4