Troubleshooting PHP Installation After Using Homebrew's mcrypt
Problem: PHP installed via Homebrew doesn't appear in phpinfo() when Apache is in use.
Check for PHP Differences:
- Run brew search php to verify if there are multiple PHP versions.
- Check the output of php -v to see which PHP version Apache is using.
Make Apache Use Homebrew PHP:
- Install the desired PHP version using brew install [email protected].
- Add the following to .zshrc (for zsh users): export PATH="/usr/local/opt/[email protected]/bin:$PATH"
- Reload .zshrc with source ~/.zshrc.
Enable PHP in Apache:
-
Add the following to httpd.conf:
- LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so
-
- SetHandler application/x-httpd-php
- Check that DirectoryIndex includes index.php.
-
Locate the configuration files:
- php.ini: /usr/local/etc/php/[PHP version]/
- php-fpm.ini: /usr/local/etc/php/[PHP version]/
The above is the detailed content of How to Resolve PHP Installation Issues After Using Homebrew\'s mcrypt?. For more information, please follow other related articles on the PHP Chinese website!