1

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();
?>

1 Answer 1

2

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.

5
  • insteading of removing them can i just disable them from running. if yes , how ?? which -a php showed these output /usr/local/bin/php /usr/bin/php /usr/local/bin/php how would i know which of them is php 5.3 ??
    – prashanthp
    Jan 21, 2014 at 19:06
  • sorry i didnt mentioned before , it is a Virtual Private Server (VPS)
    – prashanthp
    Jan 21, 2014 at 19:10
  • Edited to describe that. Jan 21, 2014 at 19:35
  • Thanks for the solution @Andrew Schulman ........ Editing the $PATH worked for me. One more thing, can we write that shell alias in a php script instead of a shell .
    – prashanthp
    Jan 22, 2014 at 9:12
  • No, because you're running the php command from the shell. You can put it into your shell startup files so it's always available, though - edited to describe that. Jan 22, 2014 at 10:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .