Linux – How to get PHP 5.3 working on Red Hat Enterprise Linux, with PDO enabled? PHP53 was installed with yum

linuxpdoPHPredhat

This problem is complicated, and I'm not an expert at all, so bear with me. My server admin team set me up with a standard RHEL box. It had PHP preinstalled, as well as apache.

I am now trying to get Drupal 7 installed on the machine, which has alerted me to a problem:

Database support Disabled

Your web server does not appear to support any common PDO database
extensions. Check with your hosting provider to see if they support
PDO (PHP Data Objects) and offer any databases that Drupal supports.

Googling this subject and talking to our server guys, it appeared that we needed to enable the PDO extensions in the php.ini file. Great, in /etc/php.ini I added the extension=pdo.so and extension=mysql_pdo.so lines.

Nothing changed, and I've got several concerns. When we search the server for a pdo.so file, it's found in a modules directory deep inside of /usr/ somewhere. We copied the path to that directory into the php.ini as extension_dir=[that path]. Restart apache, no change.

When I run php -version, I see an error message that says it can't load the dynamic library, but it's looking for the pdo.so library in /usr/local/lib/php/extensions/some-strange-no-debug-non-zts-0330i504065/ directory. Not in the directory we just set as "extensions_dir" in the php.ini. And in the phpinfo() output, it lists the extension directory like we set it in php.ini.

Second, in phpinfo() output, in the "Configure Command" section, the --disable-pdo flag is present.

If I check which php, and then navigate there, there's another file in that directory called php-config. Open that up, and TA DA! There's an "extension_dir" value that matches the /some-strange-no-debug-non-zts-92ur9u92i/ directory that was mentioned before.

Does this all need to be recompiled with the appropriate flags? Can it be fixed in php.ini? If not, how would we even go about recompiling php if it was installed with yum or rpm?

THANKS!!!

UPDATE 1
I should say, I'm using RHEL5 php53 packages. I have already run yum install php53-pdo. If I try to run yum install php-pdo (or any other non php53 php package) I get conflict errors between php53-common and php-common, which is why I started running php53 packages in the first place.

Best Answer

Assuming you're using the RHEL5 php53 packages:

# yum install php53-pdo

If you're still using the default RHEL5 PHP 5.1 RPMs then you first uninstall them all, then install everything in the php53 chain that you think you'll need.

# yum search php53

However, the RHEL php 5.3 RPMs do not support either PEAR or PECL. They're also missing some other php extensions that are available with the older RPMs. If you need any of those packages you either get to install them yourself (from source), find another repo you think you can trust, or bite the bullet and go to RHEL6. If you go with RHEL's php53 package chain, you'll absolutely want to test all of your code still works. The testing overhead may actually make it easier to go with RHEL6.