When installing PHP extensions via brew on macOS, it's crucial to ensure compatibility with Apache.
Check if brew's PHP differs from Apache's by using:
brew search php
Confirm that the version you expect is installed and add it to your PATH if necessary.
To enable PHP in Apache, follow these steps:
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch>
DirectoryIndex index.php index.html
The configuration files for PHP are located at:
/usr/local/etc/php/7.4/
You can find additional information in the Homebrew PHP formula page:
brew info php
By adhering to these instructions, you can ensure that Apache uses the PHP version installed via brew and seamlessly integrate your PHP extensions.
The above is the detailed content of How to Configure PHP and Apache with Brew on macOS for Seamless Extension Installation?. For more information, please follow other related articles on the PHP Chinese website!