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…