rosscooper rosscooper - 3 months ago 14
PHP Question

OSX El Capitan Permanently change PHP version

I have installed PHP 7.0 from here http://php-osx.liip.ch/ and followed instructions to add the new php to my

$PATH
but in a new terminal window
php -v
still shows the old default version.

The new version is used if I
source .profile
or
source .bash_profile
(tried both)

I have even added the new PHP path to my
.bashrc
but still no luck.

How can I get my mac to always use the new version of PHP by default?

Note:
Symink not an option as I'm on El Capitan.

~/.bashrc:

export PATH=/usr/local/php5/bin:$PATH
export PATH=/usr/local/bin:$PATH
export PATH=$HOME/.composer/vendor/bin:$PATH

Answer

You should use ~/.bash_profile instead of ~/.bashrc file on Mac.

If source ~/.bash_profile can solve the problem, that means the file is not sourced when you open a new terminal. If you are using zsh, you should add source ~/.bash_profile to your ~/.zshrc file.

However, brew is a better option.