0

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
/usr/bin/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

Alex
  • 139
  • 10

2 Answers2

2

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.

KingCrunch
  • 150
  • 6
2

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)

James C
  • 804
  • 1
  • 7
  • 8
  • 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 09 '11 at 08: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 09 '11 at 08: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 09 '11 at 08:40
  • 2
    @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 09 '11 at 10:29