1

I would like to upgrade my PHP from 7.2 to 7.3 on my Mac Mojave.

My current version is 7.2.25 (when I execute php -v).

I did that:

brew install php@7.3

It seems that it installed some things. But php -v still displays 7.2.25.

I restarted my computer, and still get the same. What more can I do?

halfer
  • 19,824
  • 17
  • 99
  • 186
Dom
  • 2,984
  • 3
  • 34
  • 64
  • `brew unlink php@7.2 && brew link --force --overwrite php@7.3` after running this command close all terminal and open fresh terminal to see reflection. – jagad89 Dec 07 '19 at 10:45
  • @jagad89 would that work if the 7.2 was shipped with mojave (eg i did not follow too closely brew recently ) , or would OP also need to correct is PATH env variable to point to the appropriate directory (before the shipped php path, which was the case with my box) ? – YvesLeBorg Dec 07 '19 at 10:51
  • @YvesLeBorg In that case we need to update `~/.bash_profile` as per `brew` php path. – jagad89 Dec 07 '19 at 10:54
  • @YvesLeBorg Check [this](https://stackoverflow.com/questions/20523183/how-to-use-the-php-that-brew-installed) – jagad89 Dec 07 '19 at 10:56

2 Answers2

4

need to own /usr/local/optif you face any problem to unlink or link.

sudo chown -R `whoami`:admin /usr/local/opt

brew unlink php@7.2 && brew link --force --overwrite php@7.3 after running this command close all terminal and open fresh terminal to see reflection.

To change active version with Apache,in file /usr/local/etc/httpd/httpd.conf load your desired php module. Commented php7.2 and added php7.3

#LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so
LoadModule php7_module /usr/local/opt/php@7.3/lib/httpd/modules/libphp7.so
jagad89
  • 2,603
  • 1
  • 24
  • 30
  • Hi jagad89. Thanks for you answer. When I try the command you mentionned, I have this error : Unlinking /usr/local/Cellar/php@7.2/7.2.25... 0 symlinks removed Linking /usr/local/Cellar/php@7.3/7.3.12... Error: Could not symlink sbin/php-fpm /usr/local/sbin is not writable. – Dom Dec 07 '19 at 11:05
  • run `sudo chown -R \`whoami\`:admin /usr/local/sbin` and run above command again. – jagad89 Dec 07 '19 at 11:09
  • @Dom in case if you don't have `sbin` directory under `/user/local` you need to create that directory. – jagad89 Dec 07 '19 at 11:13
  • I created sbin. And run command again : brew unlink php@7.2 && brew link --force --overwrite php@7.3. Still thesame php version : 7.2.25 – Dom Dec 07 '19 at 11:53
  • Have you closed all terminal and reopen a fresh terminal ? – jagad89 Dec 07 '19 at 11:55
  • yes I dit it . And just restarted the computer. Without success – Dom Dec 07 '19 at 11:56
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/203807/discussion-between-dom-and-jagad89). – Dom Dec 07 '19 at 11:57
  • Run **which php** it will return a path. – jagad89 Dec 07 '19 at 11:57
  • /usr/local/opt/php@7.2/bin/php – Dom Dec 07 '19 at 12:00
3

You can try to run either of the following commands

brew install php@7.3

OR

curl -s http://php-osx.liip.ch/install.sh | bash -s 7.3

And The last step is

export PATH=/usr/local/php5/bin:$PATH
Saad
  • 3,340
  • 2
  • 10
  • 32
Safi Ahmed
  • 168
  • 1
  • 3