When you installed mcrypt using Homebrew, you may encounter an issue where the PHP extension doesn't appear in your phpinfo() output. This discrepancy suggests that the PHP used by Apache differs from the version installed by Homebrew.
$ brew search php
This command will display a list of PHP versions available via Homebrew. Verify if the installed version is different from the one shown in phpinfo().
$ brew install php@7.4
$ echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
$ source ~/.zshrc
These commands install PHP 7.4, add its path to your environment, and reload your shell configuration.
Edit your Apache configuration file (typically named httpd.conf) and add the following lines:
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Ensure that DirectoryIndex includes index.php:
DirectoryIndex index.php index.html
PHP configuration files can be found in:
/usr/local/etc/php/7.4/
The above is the detailed content of How to Reconcile PHP Differences Between Homebrew and Apache?. For more information, please follow other related articles on the PHP Chinese website!