PHP(Thinkphp5)使用PDO_OCI连接Oracle 报错:
- SQLSTATE[HY000]: OCIEnvNlsCreate: Check the character set is valid and that PHP has access to Oracle libraries and NLS data
复制代码
解决方法:
php-fpm.conf 底部加上
- env[LD_LIBRARY_PATH] = /usr/lib/oracle/19.6/client64/lib
- 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 下载
- rpm -ivh oracle-instantclient19.6-basic-19.6.0.0.0-1.x86_64.rpm
- rpm -ivh oracle-instantclient19.6-devel-19.6.0.0.0-1.x86_64.rpm
- rpm -ivh oracle-instantclient19.6-sqlplus-19.6.0.0.0-1.x86_64.rpm
复制代码
软连接
- ln -s /usr/include/oracle/19.6 /usr/include/oracle/10.2.0.1
- ln -s /usr/lib/oracle/19.6 /usr/lib/oracle/10.2.0.1
复制代码
2.pdo_oci php源码包编译
- cd ext/pdo_oci
- /www/server/php/56/bin/phpize
- ./configure --with-php-config=/www/server/php/56/bin/php-config --with-pdo-oci=instantclient,/usr,10.2.0.1
- make && make install
复制代码
3.oci8 php源码包编译
- cd ext/oci8
- /www/server/php/56/bin/phpize
- ./configure --with-php-config=/www/server/php/56/bin/php-config --with-oci8=shared,instantclient,/usr/lib/oracle/19.6/client64/lib
- make && make install
复制代码
php.ini添加
- extension=oci8.so
- extension=pdo_oci.so
复制代码
重启php 看看phpinfo
|