Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I've some PHP scripts which are starting with #!/usr/bin/env php. The default interpreter is PHP 4.4, but the scripts need PHP 5.3, so I created an alias in ~/.bashrc:

alias php="/usr/local/bin/php5-53LATEST-CLI"

Thus calling php -v shows me 5.3 but #!/usr/bin/env php uses still 4.4. I wont change the scripts. So how can I get PHP 5.3 with #!/usr/bin/env php?

share|improve this question
You will change the scripts. Or get rid of PHP 4.4. – Michael Hampton Mar 5 '14 at 11:15
up vote 3 down vote accepted

/usr/bin/env php looks for an executable named php in the current $PATH; it pays no attention to aliases, shell functions, etc. If you want it to execute php v5.3, you have to put that version in a directory under the name php, and put that directory in your PATH somewhere before the directory that contains version 4.4. Maybe something like this:

mkdir /usr/local/bin/php-overrides
ln -s /usr/local/bin/php5-53LATEST-CLI /usr/local/bin/php-overrides/php

...then add


to your ~/.bash_profile (or other appropriate startup script).

share|improve this answer

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.