php获取远程https内容时提示 PHP Warning: copy(): Unable to find the wrapper “https“ 解决方法

异常信息:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

PHP Warning: copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1

PHP Stack trace:

PHP 1. {main}() Command line code:0

PHP 2. copy(source_file = 'https://getcomposer.org/installer', destination_file = 'composer-setup.php') Command line code:1

Warning: copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1

Call Stack:

0.0001 388024 1. {main}() Command line code:0

0.0008 388024 2. copy(source_file = 'https://getcomposer.org/installer', destination_file = 'composer-setup.php') Command line code:1

异常原因

这个异常是因为当前的php没有配置openssl模块, 所以在php访问https的内容时就提示 Unable to find the wrapper "https" 异常。

解决方法: 安装 openssl扩展

在macos中通过macport安装php后,默认是没有安装openssl扩展的, 需要我们手动安装一下这个openssl的扩展。

bash 复制代码
# 首先确定当前php版本
php -version

# 然后安装 openssl扩展 , 这里以php7.2版本为例
sudo port install php72-openssl

如果你的php非port安装的,解决方法也是一样的,安装对应php的 openssl 扩展即可。

通过port search查找可用的php openssl扩展包参考

命令: port search --name --line --regex '^php(\d+)-openssl'

相关推荐
Acrelhuang2 分钟前
直击新能源电能质量痛点:安科瑞 APView500 在线监测装置应用方案
大数据·运维·开发语言·人工智能·物联网
无限进步_9 分钟前
C++从入门到类和对象完全指南
开发语言·c++·windows·git·后端·github·visual studio
lalala_lulu12 分钟前
Lambda表达式是什么
开发语言·python
她说..12 分钟前
Java AOP完全指南:从原理到实战(全套知识点+场景总结)
java·开发语言·spring·java-ee·springboot
Sammyyyyy12 分钟前
Rust性能调优:从劝退到真香
开发语言·后端·rust·servbay
Zfox_17 分钟前
【Go】异常处理、泛型和文件操作
开发语言·后端·golang
zhangyanfei0120 分钟前
谈谈 Golang 中的线程协程是如何管理栈内存的
开发语言·后端·golang
浪客川24 分钟前
高效日志分离器:一键筛选关键信息
开发语言·windows·c#
星竹晨L27 分钟前
C++红黑树:理论与实践相结合的平衡艺术
开发语言·数据结构·c++
itwangyang52028 分钟前
在 GitHub 上生成和配置个人访问令牌(PAT),并将其用于 R 环境中的凭证管理和包安装。
开发语言·r语言·github