PHP usage issues with many Homebrew errors when reinstalling after macOS Monterey update
P粉561749334
P粉561749334 2023-12-12 19:45:58
0
1
504

I made the seemingly wrong decision to update to macOS Monterey 12.3.1 and am having trouble trying to get PHP to run on it again. As far as I know, Apple has decided to deprecate PHP - at least from their machines, and they removed every php version and setting I had for all my Laravel and Wordpress projects!

I tried to reinstall PHP using homebrew but I got a lot of errors and some packages couldn't be downloaded due to authorization denied?

I then tried uninstalling and reinstalling Homebrew and did the following:

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Add the following content to zshrc

eval "$(/opt/homebrew/bin/brew shellenv)"

Test the brew version to see if it works properly

brew --version

Run brew doctor to make sure everything is configured correctly

brew doctor

I also found out that there might be libraries missing and I should reinstall open ssl, so I did that too:

brew install openssl

Then for PHP I run:

brew tap shivammathur/php

Then

brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@8.0

I even restarted the php service just in case

brew services restart shivammathur/php/php@7.4 
brew services restart shivammathur/php/php@8.0

Then I ran away

php -v

I get the following error:

zsh: command not found: php

and where php says php not found

What the hell!

Then I tried to unlink php and force link to 7.4:

brew unlink php && brew link --overwrite --force php@7.4

I get the following error:

Error: No such keg: /usr/local/Cellar/php

I've tried to dig into this keg issue but I haven't been able to figure it out, do you have any suggestions for next steps

P粉561749334
P粉561749334

reply all(1)
P粉366946380

Check whether Homebrew's bin directory, i.e. $(brew --prefix)/bin, is in your PATH.

If you want to link against PHP 7.4, please run

brew link --overwrite --force php@7.4

If you get an error message saying it's already linked, you can unlink it and then link it again to make sure it's relinked. Make sure to unlink the correct version.

brew unlink php@7.4
brew link --overwrite --force php@7.4
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template