search

Home  >  Q&A  >  body text

How to force installation of PHP 8.1 using Homebrew?

I installed MAMP on my mac, using the php version 7.4.

command which php

Return - /Applications/MAMP/bin/php/php7.4.21/bin/php

I have installed php 8.1 using brew. I commented ~/.bash_profile

# export PATH=/Applications/MAMP/bin/php/php7.4.21/bin:$PATH
# alias mysql=/Applications/MAMP/Library/bin/mysql
# export PATH="/usr/local/opt/node@13/bin:$PATH"

But it still shows the same php path. How to switch to newly installed php version?

P粉744831602P粉744831602379 days ago713

reply all(1)I'll reply

  • P粉020556231

    P粉0205562312023-11-09 20:33:01

    You must link the PHP version you want to use.

    brew unlink php will unlink the current version of PHP.
    brew link php@8.1 Will link to PHP 8.1 (you need to install it first)

    reply
    0
  • Cancelreply