无法在CentOS上安装PDO

时间:2013-10-10 17:08:03

标签: php mysql pdo centos

我知道在整个stackoverflow中有几个这个问题的实例,但我找不到解决方案。

我使用Apache和PHP 5.3运行CentOS

.php脚本给了我这个错误:

Fatal error: Class 'PDO' not found in ...

我运行phpinfo();,页面上唯一存在“pdo”的位置是“配置命令”'--disable-pdo'行。

我尝试了#yum install php-pdo,但没有包。

我还尝试了#pecl install pdo,最后我得到了这些错误:

/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_stmt_instantiate':
/root/tmp/pear/PDO/pdo_dbh.c:410: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c:411: error: 'zval' has no member named 'is_ref'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_stmt_construct':
/root/tmp/pear/PDO/pdo_dbh.c:435: error: 'zend_fcall_info' has no member named 'object_pp'
/root/tmp/pear/PDO/pdo_dbh.c:458: error: 'zend_fcall_info_cache' has no member named 'object_pp'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'zim_PDO_setAttribute':
/root/tmp/pear/PDO/pdo_dbh.c:752: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'zim_PDO_getAttribute':
/root/tmp/pear/PDO/pdo_dbh.c:818: error: 'zval' has no member named 'refcount'
/root/tmp/pear/PDO/pdo_dbh.c: In function 'pdo_hash_methods':
/root/tmp/pear/PDO/pdo_dbh.c:1122: warning: assignment discards qualifiers from pointer target type
/root/tmp/pear/PDO/pdo_dbh.c:1126: warning: assignment discards qualifiers from pointer target type
make: *** [pdo_dbh.lo] Error 1
ERROR: `make' failed

然后在php.net doc上它基本上说这个包是自PHP 5.1以来在PHP安装中的标准。

我将行extension=pdo.so添加到php.ini并重新启动Apache,问题仍然存在。有什么建议吗?

3 个答案:

答案 0 :(得分:1)

我也遇到过类似的问题。我正在使用codeigniter并且收到“pdo_mysql.so not found”错误并尝试了一切来修复它。我必须通过谷歌搜索结果的前10页搜索多个查询。我发现很多人有同样的问题,但由于某些原因,他们都没有答案/修复。通过所有这些阅读,我了解到“ PDO和PDO_SQLITE驱动程序默认启用,从PHP 5.1.0开始。 ”这让我想到,“也许我应该从我的php.ini 中删除extension = pdo_mysql.so和pdo.so行!“我认为php正试图加载一个不再存在的扩展,因为它现在已经内置了。果然,解决了我所有的php错误。

  

PHP 5.4.31(cli)(建于2014年8月19日10:38:48)
  Zend Engine v2.4.0,版权所有(c)1998-2014 Zend Technologies
  服务器版本:Apache / 2.2.27(Unix)
  服务器内置:2014年8月19日10:33:30
  Cpanel :: Easy :: Apache v3.26.5 rev9999

答案 1 :(得分:0)

我很确定你错过了PHP_PDO包。尝试通过运行命令bellow:

找到PDO包
 # rpm -qa| grep "pdo"

我的节目是php53u-pdo-5.3.26-1.ius.el5

如果您使用的是php 5.3,请尝试

# yum install php53u-pdo

答案 2 :(得分:0)

我不知道答案是否为时已晚,但如果有人发现此错误,我会发帖。

首先,我在Centos 7中使用yum安装了php-pdo。我查看了phpinfo,它显示了pdo扩展,但没有显示pdo-mysql。

所以,如果你再安装php-mysql(yum install php-mysql),它会自动安装pdo-mysql扩展。

相关问题