Mac环境下如何为PHP 8安装openssl与curl扩展?
问题:Homebrew安装PHP 8后无法启用curl/openssl扩展
操作步骤
- 执行命令安装PHP 8:
brew install php - 编辑
php.ini文件,添加以下配置启用扩展:extension=curl extension=openssl - 使用的默认扩展目录配置:
extension_dir = "/opt/homebrew/lib/php/pecl/20220829"
报错信息
启动PHP时出现如下警告(curl扩展的报错内容类似):
PHP Warning: PHP Startup: Unable to load dynamic library 'openssl' (tried: /opt/homebrew/lib/php/pecl/20220829/openssl (dlopen(/opt/homebrew/lib/php/pecl/20220829/openssl, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20220829/openssl' (no such file)), /opt/homebrew/lib/php/pecl/20220829/openssl.so (dlopen(/opt/homebrew/lib/php/pecl/20220829/openssl.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20220829/openssl.so' (no such file))) in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library 'openssl' (tried: /opt/homebrew/lib/php/pecl/20220829/openssl (dlopen(/opt/homebrew/lib/php/pecl/20220829/openssl, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20220829/openssl' (no such file)), /opt/homebrew/lib/php/pecl/20220829/openssl.so (dlopen(/opt/homebrew/lib/php/pecl/20220829/openssl.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20220829/openssl.so' (no such file))) in Unknown on line 0
尝试解决的结果
执行命令尝试通过pecl安装openssl扩展:
pecl install openssl
返回结果:
No releases available for package "pecl.php.net/openssl" install failed
目前/opt/homebrew/lib/php/pecl/20220829目录为空,无法确定curl和openssl扩展文件的实际位置。
内容的提问来源于stack exchange,提问作者Adam
相关产品推荐
相关产品推荐

