在CentOS 5.4上运行PHP 5.3 -致命错误Class 'PDO'没有找到


Running PHP 5.3 on CentOS 5.4 - fatal error Class 'PDO' not found

让PHP 5.3在CentOS 5.4上运行的最好方法是什么?我的机器说我已经安装了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包

安装pdo
安装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
"

现在我得到一个mysql_query_missing当尝试运行sudo pecl安装pdo_mysql
我不知道如何通过这个

您还必须安装php-pdo包。

编辑:也许这也有帮助:我如何使用CentOS启用PDO ?

我已经成功地在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的完整工作步骤(我提供了以#开头的注释-您不需要这些,仅供参考)

# 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