Running macOS Sierra.
How can I complete remove all links to the default installed PHP version? I have installed PHP 7 through homebrew but when I run scripts that call external CLI applications programatically they still seem to end up using PHP 5.6.25 which is the default installed PHP version.
What can I do to break all ties to this PHP version?
My php -v and phpinfo() already show the proper PHP7 version that I installed. Somehow some scripts still try to look for the default version.
I already read you cannot simply delete it.
If you need more info please let me know.
asked Feb 13, 2017 at 1:26
Try this:
sudo mv /usr/bin/php /usr/bin/php5 sudo ln -s `which php` /usr/bin/phpThe first command backs up the old PHP binary. It can still be used by invoking php5 in a command line. The second command symlinks the new PHP 7 binary to the location of the old PHP binary. Therefore, scripts that use the old location will start using the new PHP version.
answered Feb 13, 2017 at 1:54
Faiz SaleemFaiz Saleem
2,1251 gold badge11 silver badges32 bronze badges
You must log in to answer this question.
Not the answer you're looking for? Browse other questions tagged
.
In my mac (version 10.13.6 High Sierra) php -v output is PHP 7.1.32 . I need to update this 7.1 version to 7.3.
i tried to remove this version using brew unlink php7.1 but it's not worked.
How can i upgrade php version.
asked Feb 19, 2020 at 7:54
$ brew upgrade php : ( get the latest homebrew php packages )
$ brew install : ( Install php 7.4 )
$ brew link : ( create an alias to this keg-only version; see comments output during installation )
$ echo 'export PATH="/usr/local/opt//bin:$PATH"' >> ~/.bash_profile : ( Add the alias to your path; see comments output during installation )
$ source ~/.bash_profile : ( Reload .bash_profile to use the new settings immediately )
Reference : How to use the php that brew installed?
answered Feb 19, 2020 at 9:49
C.VC.V
8311 gold badge9 silver badges20 bronze badges
1
First:
~ brew updatethen install the latest php version (PHP 8.0.8 in the time of writing):
~ brew install phplink new version to /usr/local/Cellar/php/8.0.8:
~ brew link phpthen open the shell's resource file, located in ~/ (in my case Z-shell or ZSH):
~ sudo vi .zshrcpress i to insert and somewhere in your resource file append a new path to your $PATH variable, like this:
export PATH=$PATH:/usr/local/opt//binor in the case of ZSH, you should also be able to do it like this:
path+=('/usr/local/opt//bin') export PATHthen press esc to escape from insert mode, and press :wq to save/write and quit the editor. The final step is to source the file to apply new changes permanently.
~ source .zshrcTry new PHP version:
~ php -vanswered Jul 2, 2021 at 0:40
0
I am not sure about the 10.13.6 High Sierra version, but this worked for me.
php -v (To see what version php has. But you have already done that)
brew unlink php55 (In my case I use php 5.5)
brew install php73 (For the php 7.3 version.)
php -v (To check of the version is the one I need.)
Hope this helps.
answered Feb 19, 2020 at 8:39
MalgoshMalgosh
3401 silver badge9 bronze badges
I solved the problem maintaining homebrew for both of the arch (arm64 and x86_64). In that case I choose Homebrew location dynamically depending on the terminal arch in my .bashrc.
if [[ $(uname -m) == "x86_64" ]]; then echo "x86_64 detected" export PATH=/usr/local/Homebrew/bin:$PATH else echo "arm64 detected" export PATH=/opt/homebrew/bin:$PATH fiAnd installed tmux in both of the terminal (native and rosetta) and after reload it works correctly. Full .zshrc can be found here.
answered Dec 26, 2021 at 18:02
Rafik FarhadRafik Farhad
1,0902 gold badges14 silver badges20 bronze badges