Php – Running PHP 5.3 on CentOS 5.4 – fatal error Class ‘PDO’ not found

centospdoPHP

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.

Best Answer

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

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

Related Topic