TransWikia.com

how to not use the default PHP 7.3 of Mac OSX Catalina 10.15.6 and use home brew php?

Stack Overflow Asked on December 20, 2021

I was given a macbook 2019 for work which has catalina 10.15.6 … the default PHP is 7.3 .. can someone show me the step by step on how to avoid this default PHP version?. I found some tutorials online using homebrew in order to use multiple versions of PHP. but then am a bit skeptical to install the homebrew php yet, coz I scare it will conflict with the default PHP with the OSX . any idea ?

2 Answers

Homebrew manages the installation for you and updates the necessary paths.

With homebrew installed you can just run the following command to install php7.4

brew update
brew install [email protected]

Check your PHP version now

php -v

If it still prints out the old version, update your path:

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

Alternative one-line install

curl -s https://php-osx.liip.ch/install.sh | bash -s 7.4

Answered by Clement Sam on December 20, 2021

To do that, Within the terminal, Fire this command:

which php

This should output the path to the default PHP install which comes preinstalled by Mac OS X, by default it has to be Now, We just need to swap this over to the PHP that is installed with MAMP, which is located at /Applications/Xampp/bin/php/php7.3/bin for example

  1. Within the Terminal, run vim ~/.bash_profile

  2. Type i and then paste the following at the top of the file:

export PATH=/Applications/Xampp/bin/php/php7.3/bin:$PATH

  1. Hit ESC, Type :wq, and hit Enter

In Terminal, run source ~/.bash_profile

  1. In Terminal, type in which php again and look for the updated string. If everything was successful, It should output the new path to MAMP PHP install.

  2. In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).

source : https://gist.github.com/irazasyed/5987693

Answered by josue tchirktema on December 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP