Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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 '14 at 19:06
sorry i didnt mentioned before , it is a Virtual Private Server (VPS) – prashanthp Jan 21 '14 at 19:10
Edited to describe that. – Andrew Schulman Jan 21 '14 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 '14 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. – Andrew Schulman Jan 22 '14 at 10:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.