Php -i executed from command line and phpinfo executed from browser show different php parameters

apache-2.2command-line-interfacePHPzend-framework

My problem is that when I execute php -i it shows the php version as php 5.4 and the loaded config file as /usr/local/lib/php.ini. When I execute the script phpinfo.php from the command line it shows php 5.3 and the loaded config file as /etc/php.ini.

How can I enable the default PHP interpreter as php 5.3?

I need 5.3 because php 5.3 is configured with PDO and pdo_mysql where php 5.4 is not configured with it also the zend version of php 5.3 is 220090626 whereas that of php 5.4 is 220090525.

When I try to execute a PHP script from a browser it is being compiled with php 5.4 (which doesn't have the PDO extension) and is throwing a fatal error as undefined PDO.

How do I configure my Apache to load php 5.3 for the scripts.

The phpinfo.php script is as follows

<?php
phpinfo();
?>

Best Answer

Your php.ini is in /usr/local/lib? That's so completely wrong, no package manager would put that file there.

You must have a locally built copy of php on your host. which php will show you where it is. which -a php will show you all of the installed versions of php that are in your $PATH. Run php -v on each one to see which version it is.

Remove the versions you don't want, and you'll have php 5.3 left. If you can't remove them, then change your $PATH so the one you want comes first, e.g. PATH=/usr/bin:/usr/local/bin if you want /usr/bin/php instead of /usr/local/bin/php. Or, define a shell alias:

alias php=/usr/bin/php

and put it into your shell startup files (~/.bashrc or ~/.profile) so that that version always gets run when you type just php.