0

General

I am using macOS 10.13.6

So, what I want is to work with laravel 8, which requires php 8, and what I did was installing php@8.0 via homebrew:

$ brew update
$ brew tap shivammathur/php
$ brew install shivammathur/php/php@8.0

PHP 8 was installed successfully and after that, I ran this command:

$ brew link --overwrite --force php@8.0
Linking /usr/local/Cellar/php/8.0.9... 24 symlinks created.

After that I went to .bash_profile and exported /usr/local/Cellar/php/8.0.9/bin and /usr/local/Cellar/php/8.0.9/sbin to the $PATH sysvar, saved the changes and executed the command:

$ source .bash_profile restart
$ php -v
PHP 7.1.33 (cli) (built: Jan 18 2020 13:49:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

What I did next

Then I decided to check StackOverflow to find some useful info that could help me out. Here it said:

tell your terminal where to find your new installed php.

export PATH="/usr/local/opt/php@8.0/sbin:$PATH"

Since /usr/local/opt/php@8.0 is a pointer to /usr/local/Cellar/php/8.0.9/, it must work as well (but it does not). Messing up with $PATH for some time has lead to nothing but a strong headache, so I decided to continue my search… Here it said:

You have to make your Apache use the PHP that you just downloaded.

I didn't know if I really needed that, but just in case I did, I added

LoadModule php8_module /usr/local/Cellar/php/8.0.9/lib/httpd/modules/libphp.so 

to the apache httpd.conf file and ran:

$ sudo apachectl restart

Nothing happened. Another one contained the list of instructions, which looked like this:

  • brew install php@<desired_package>
  • brew link --force php@<desired_package>
  • brew services start php@<desired_package>
  • export PATH="/usr/local/opt/php@<desired_package>/bin:$PATH"
  • export PATH="/usr/local/opt/php@<desired_package>/sbin:$PATH"

That one did not work either. I'm stuck. I do not know what to do. Please, help. Thanks in advance.

EDIT: These steps did work for php@7.4 actually. Seems one cannot upgrade to php 8 on a machine running macOS High Sierra…

1 Answers1

0

Add the bin directory in Homebrew's prefix to your path, then the linked PHP version should work.

echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile && source ~/.bash_profile

Also, please upgrade your macOS. Homebrew does not support High Sierra now.

Shivam Mathur
  • 2,543
  • 19
  • 26
  • I'd love to upgrade to newer versions of macOS, but I have MacBook Pro early 2011 – Mikich Esaian Nov 08 '21 at 05:55
  • Added `bin` to `PATH` and that didn't solve the problem. Still running php@7.4 – Mikich Esaian Nov 08 '21 at 06:00
  • 2
    Try unlinking `php@7.4` and relinking `php@8.0` -> `brew unlink php@7.4 && brew unlink php@8.0 && brew link --force --overwrite php@8.0` Also, make sure you did not add php@7.4 location to your PATH, remove that if that is in the PATH – Shivam Mathur Nov 08 '21 at 06:14