2

What is the best way to get PHP 5.3 up and running on CentOS 5.4. My machine says I have PHP 5.3 installed but running into an issue with my script that says Fatal error: Class 'PDO' not found in /var/www/html/lib/rb.php on line 45 It fails trying to new up a PDO class in the RedbeanPHP 3.0 lib.

How can I fix this missing PDO problem?

I tried to follow these instructions: from 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  

UPDATE
Someone removed their answer. It was good. I'm putting it back in with exact steps. First I had to yum install php53u-devel
To quote "
You need the PDO extension. Usually the best way to install extensions is via PECL.

Before you can install any PECL extensions you need to install the php5-dev package

sudo pecl install pdo
sudo pecl install pdo_mysql
You then need add the following to the end of your php.ini file(s). Depending on which version of PHP you installed they’ll be /etc/php5/apache2/php.ini, /etc/php5/cgi/php.ini and /etc/php/cli/php.ini.

extension=pdo.so
extension=pdo_mysql.so
"

Now I get a mysql_query_missing when trying to run sudo pecl install pdo_mysql
and not sure how to get past this.

hakre
  • 193,403
  • 52
  • 435
  • 836
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466

2 Answers2

2

You'll have to install the php-pdo package as well.

Edit: Maybe this helps as well: How do I enable PDO using CentOS?

Community
  • 1
  • 1
TimWolla
  • 31,849
  • 8
  • 63
  • 96
1

I have been successfully able to install PHP-5.3 on CentOS 5.4 Linux. I needed this to be able to successfully install and run Drupal 7 - which also worked out for me. Here are the details:

This is a copy of the answer I wrote up in ServerFault: https://serverfault.com/a/392168/29205

(...for my question: https://serverfault.com/questions/391772/php-xml-install-complains-of-dependency-php-common-but-this-is-already-installed/392168#392168 )

The solution is based on the accepted answer in:

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

In summary: move to php5.3.

Reason: support for php5.2 as been removed owing to security issues as explained in that other question's accepted answer. This removal causes mismatch of the versions of the dependencies and therefore the error seen.

Background

I wanted to run Drupal 7 on a CentOS 5.4 machine. So I needed 5.3 version of PHP.

Here are the full working steps to upgrade to PHP 5.3 with working repositories as of May 24 2012 ( I provide comments preceded by # - you don't need these, just for your info)

# 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
Community
  • 1
  • 1
therobyouknow
  • 6,604
  • 13
  • 56
  • 73