Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
605 views
in Technique[技术] by (71.8m points)

homebrew - Switch of php versions not working on mac

I have High Sierra installed and it comes with php 7.1. During the environment I ended up being able to upgrade to php7.2 but wasn't able to document it, so I dont exactly know what I did. Now, I am trying to switch to php 7.3

Using brew, I ran the following commands:

brew unlink php@7.2

brew services install php@7.3

brew link php@7.3

If I restart my terminal and check for the php version:

php -v

I still see 7.2.25 version and not 7.3 as I desire

I also tried with a node package that I found in this link here but no success.

How do I successfully switch between php versions?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is my installation script:

  • brew install php@7.2
  • brew link --force php@7.2
  • brew services start php@7.2
  • export PATH="/usr/local/opt/php@7.2/bin:$PATH"
  • export PATH="/usr/local/opt/php@7.2/sbin:$PATH"

Now my output would be as:

$ php -v
PHP 7.2.25 (cli) (built: Nov 22 2019 10:27:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.25, Copyright (c) 1999-2018, by Zend Technologies

I think the PATH environment setup is something matters. And it does show in instructions as part of the installation process though.

Hope it helps resolving your issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...