【问题标题】:Running PHP 5.3 on CentOS 5.4 - fatal error Class 'PDO' not found在 CentOS 5.4 上运行 PHP 5.3 - 找不到致命错误 Class 'PDO'
【发布时间】:2012-01-26 23:33:59
【问题描述】:

在 CentOS 5.4 上启动和运行 PHP 5.3 的最佳方法是什么。 我的机器说我安装了 PHP 5.3,但我的脚本遇到了一个问题,上面写着 致命错误:在第 45 行的 /var/www/html/lib/rb.php 中找不到类“PDO” 尝试在 RedbeanPHP 3.0 库中新建 PDO 类失败。

如何解决这个缺失的 PDO 问题?

我尝试按照以下说明进行操作: 来自http://www.computingunplugged.com/issues/issue201102/00002619002

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm  
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm  
# THIS LINE FAILED FOR ME
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-6.ius.el5.noarch.rpm  

yum erase php php-pear php-mysql php-cli php-common  

yum install php53u php53u-pear php53u-cli php53u-common php53u-gd  
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap  
yum install php53u-xml php53u-xmlrpc php53u-bcmath  

更新
有人删除了他们的答案。这很好。我正在用确切的步骤把它放回去。 首先我必须 yum 安装 php53u-devel
引用“
您需要 PDO 扩展。通常安装扩展的最佳方式是通过 PECL。

在安装任何 PECL 扩展之前,您需要安装 php5-dev 包

sudo pecl 安装 pdo
sudo pecl 安装 pdo_mysql
然后,您需要将以下内容添加到 php.ini 文件的末尾。根据您安装的 PHP 版本,它们将是 /etc/php5/apache2/php.ini、/etc/php5/cgi/php.ini 和 /etc/php/cli/php.ini。

扩展=pdo.so
扩展=pdo_mysql.so
"

现在我在尝试运行 sudo pecl install pdo_mysql 时得到一个 mysql_query_missing
不知道如何解决这个问题。

【问题讨论】:

  • 从哪里可以得到 php5-dev 包?我需要添加什么仓库?

标签: php pdo centos


【解决方案1】:

您还必须安装 php-pdo 软件包。

编辑:也许这也有帮助:How do I enable PDO using CentOS?

【讨论】:

  • 我能够安装 - yum install php53u-devel
  • @brunot 你想告诉我什么?
  • 最后...我猜我已经有了 .so 文件,所以我只是在我在问题中概述的所有其他步骤之后添加了 php ini 设置。
  • 尽量为下一个发现此问题的人提供更多信息,这样可以避免像我一样询问小型后续问题。谢谢。 +1
【解决方案2】:

我已经能够在 CentOS 5.4 Linux 上成功安装 PHP-5.3。我需要它才能成功安装和运行 Drupal 7——这对我来说也很有效。详情如下:

这是我在 ServerFault 中写的答案的副本:https://serverfault.com/a/392168/29205

(...对于我的问题:https://serverfault.com/questions/391772/php-xml-install-complains-of-dependency-php-common-but-this-is-already-installed/392168#392168

解决方案基于接受的答案:

https://serverfault.com/questions/391839/how-to-force-centos-yum-to-use-a-later-version-of-a-package-dependency-already-i

总结:迁移到 php5.3。

原因:由于安全问题,已删除对 php5.2 的支持,如其他问题已接受的答案中所述。此删除会导致依赖项版本不匹配,从而导致出现错误。

背景

我想在 CentOS 5.4 机器上运行 Drupal 7。所以我需要5.3版本的PHP。

以下是截至 2012 年 5 月 24 日使用工作存储库升级到 PHP 5.3 的完整工作步骤(我提供了以 # 开头的 cmets - 您不需要这些,仅供参考)

# Comment: sites like http://www.computingunplugged.com/issues/issue201102/00002619001
# provide a good start for remedying the problem whereby we need 5.3 on CentOS 5.4 to run Drupal 7. But although their packages worked at the time, the links are now outdated, and updates to these are below.


# comment: (as of May 2012 - the following work, the reason for failures was use of 1) older packages no longer on the server and 2) change of address of one of the servers to dl.fedoraproject.org/pub/epel (credit to: http://osdir.com/ml/centos/2012-03/msg00057.html )

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-10.ius.el5.noarch.rpm  

yum erase php php-pear php-mysql php-cli php-common  

yum install php53u php53u-pear php53u-cli php53u-common php53u-gd  
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap  
yum install php53u-xml php53u-xmlrpc php53u-bcmath 


# After doing the above, php -v shows 5.3.x But on attempting to install Drupal 7 you may get complaint of something "Your PHP installation is too old 5.1.6 Drupal requires at least PHP 5.2.4. See the system requirements page for more information." and php.info shows the same

# The remedy is to simply restart your apache server

service httpd restart

# credit to following for suggesting service httpd restart :-
# https://serverfault.com/a/207806/29205
# https://serverfault.com/questions/207762/centos-updating-php-via-yum-doesnt-change-the-version-apache-uses

# Drupal 7 install on CentOS 5.4 worked after applying the above steps

# If your MySQL server is not running (check by ps -ef | grep mysql ) then you can run:

/etc/init.d/mysqld

# ...to start it, and to make sure it starts when the machine is restarted or cold booted:

chkconfig mysqld on

【讨论】:

    猜你喜欢
    • 2012-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-28
    • 1970-01-01
    相关资源
    最近更新 更多