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'm on a Mac, and it has PHP 5.3.4 built in.

I downloaded the sources of PHP 5.3.6 and installed it via

./configure; sudo make; sudo make install

It is now installed in /usr/local/bin/php:

/usr/local/bin/php  -v
PHP 5.3.6 (cli) (built: May  9 2011 12:04:28) 

However when I run the php command, I still get old php version:

php -v
PHP 5.3.4 (cli) (built: Dec 15 2010 12:15:07) 

The location is also different:

which php

I can run the scripts with new PHP by specifying the full path, but how can I make it like

php5.3.6 hello_world.php


Thank you

share|improve this question

migrated from May 9 '11 at 9:14

This question came from our site for professional and enthusiast programmers.

Have you edited your apache conf? – JohnP May 9 '11 at 8:17
There is no need for sudo when using make. Only make install might need rootpermissions to write to protected directories. – Lekensteyn May 9 '11 at 9:21
up vote 2 down vote accepted

You will probably want to use the alias command.

Assuming you're using bash create a file called ~/.bash_aliases

and add the following to it:

alias php5.3.6="/usr/local/bin/php"
alias php5.3.4="/usr/bin/php"

I'd recommend only having one version of PHP installed at a time and unless you really need to compile from source would suggest you use some kind of packaged binary install (like an RPM or .deb package)

share|improve this answer
Thanks! That's exactly what I was looking for... Didn't know about aliasing. I love *nix more and more with every day – Alex May 9 '11 at 8:21
if the .bash_aliases file isn't parsed (I don't have a mac to verify) then try adding it to ~/.bashrc – James C May 9 '11 at 8:24
In fact I just ran the command alias php5.3.6="/usr/local/bin/php" in terminal, and it worked! I didn't even have to edit any files. – Alex May 9 '11 at 8:40
@Alex: The issue is that alias doesn't persist across reboots (or indeed, even across sessions!). If you want it to work consistently, you'll need to add it to a file somewhere. – BMDan May 9 '11 at 10:29

You can create a symlink in /usr/bin. Dont know mac very well. Under linux its like

ln -s /usr/local/bin/php /usr/bin/php5.3.6

Should be similar under the apple.

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.