Update PHP to 7.4 macOS Catalina with brew
54,883
Solution 1
try:
brew update
brew upgrade php
php -v
brew services start php
or
brew services restart php
if you use apache server:
sudo apachectl restart
if you use ngnix
sudo nginx -s reload
Edit:
brew unlink [email protected]
brew link [email protected]
Solution 2
You can find my similar answer for [email protected].
brew install [email protected]
brew link --force --overwrite [email protected]
brew services start [email protected]
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
Solution 3
If anyone want to downgrade php from latest 8.1.2 to 7.4 on systems demand, try the below commands with homebrew: Installing PHP 7.4 :
brew install [email protected]
brew services restart php
brew unlink [email protected]
brew link [email protected]
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
Or
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
Solution 4
Using terminal of MacOS. Don't use terminal in vscode.
Author by
meez
Updated on February 08, 2022Comments
-
meez about 2 years
I try to update my PHP version to
7.4
on macOS Catalina with brew.I did
brew install [email protected]
If I check my version
php -v
, I still see the old versionPHP 7.3.11
?What do I have to do?
Update:
After
brew doctor
I get:Warning: Homebrew's sbin was not found in your PATH but you have installed formulae that put executables in /usr/local/sbin. Consider setting the PATH for example like so: echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.profile
-
meez over 3 yearsthanks but after trying above, it still show PHP 7.3.11? I need to update to 7.4 because of composer's dependencies.
-
Salines over 3 years@meez. after services restart ?
-
meez over 3 yearsAfter
brew unlink [email protected]
I getError: No such keg: /usr/local/Cellar/[email protected]
? -
Salines over 3 years@meez run brew doctor
-
juanitourquiza over 3 yearsThis solution works perfectly in MacOS BigSur.
-
Jannie Theunissen over 3 yearsInstead of link --force I had to do
brew link --overwrite [email protected]
-
chenrui over 3 yearsyeah, add
--overwrite
to the OP (it would consider the existing php links), thanks Jannie! -
Ben Fransen almost 3 yearslife saver on BigSur!
-
jo-chris over 2 years96 upvotes is not enough! Thank you! Works on BigSur 11.4
-
Andres SK over 2 yearsI'm doing this in Catalina but
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
seems to take forever. -
M Uzair Qadeer over 2 yearsit's good and working well on OSX Monterey
-
Nenad Kaevik over 2 yearsWorks like a charm on BigSur
-
Justin Hammond over 2 yearsOddly enough, this did the trick even though I've linked/unlinked taps various times successfully from the VS Code terminal.
-
Xab Ion almost 2 yearsWorks perfectly on macOS Catalina. Thanks.