Fatal Error: Class 'mysqli' not found in...错误的解决方法

环境:centos5.5+php-5.2.17+nginx-0.7.65

在访问某程序的时候,页面出错:Fatal Error: Class ‘mysqli’ not found in…

解决方法:

方法1:

编辑php.ini文件,去掉extension=php_mysqli.dll前面的注释。(网上找的,没有成功)

方法2:

cd php-5.2.17/ext/mysqli

/usr/local/php/bin/phpize #执行完后就出了configure文件,

./configure –prefix=/usr/local/mysqli –with-php-config=/usr/local/php/bin/php-config –with-mysqli=/usr/local/mysql/bin/mysql_config

make

make install (不出错就会显示Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20041030/)

编辑php.ini文件:

把extension_dir=”./“

改为

extension_dir=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20041030/”

添加 extension=mysqli.so
 

然后重启nginx和php-fpm,访问正常。