After installing a package, Homebrew shows you some helpful information you have to notice that information.
Anyway, you can access that information after that, by running below command.
brew info [email protected]
If you notice there is a Caveats section like below, it contains some configurations you have to do manually.
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.4/
[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have [email protected] first in your PATH, run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
For compilers to find [email protected] you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
To restart [email protected] after an upgrade:
brew services restart [email protected]
Or, if you don't want/need a background service you can just run:
/usr/local/opt/[email protected]/sbin/php-fpm --nodaemonize
In your case, you have to add bellow lines to your shell runcom file by runing these commands in your terminal, if you using Zsh it whould be ~/.zshrc
if you are using Bash, it would be ~/.bashrc
.
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> path/to/runcom/file
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> path/to/runcom/file
This would add your PHP installed by Hombrew in the path, and prefer it over macOS bundled PHP.