Home  >  Q&A  >  body text

PHP usage issues with many Homebrew errors when reinstalling after macOS Monterey update

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粉561749334P粉561749334286 days ago410

reply all(1)I'll reply

  • P粉366946380

    P粉3669463802023-12-13 00:24:16

    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

    reply
    0
  • Cancelreply