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'

相关推荐
pingan87878 分钟前
试试 docx.js 一键生成 Word 文档,效果很不错
开发语言·前端·javascript·ecmascript·word
2401_844221328 分钟前
深入理解K8s中的应用服务:访问、集群与配置
容器·kubernetes·php
big_rabbit050213 分钟前
java面试题整理
java·开发语言
刺客xs27 分钟前
c++模板
java·开发语言·c++
weixin_5375904534 分钟前
《C程序设计语言》练习答案(练习1-5)
c语言·开发语言
阳光永恒73637 分钟前
Python零基础入门全套资料包免费分享 | 从0到1系统学习路线(含课件+源码+实战案例)
开发语言·python·学习·编程入门·python教程·编程学习·免费资料
紫丁香40 分钟前
pytest_自动化测试1
开发语言·python·功能测试·单元测试·pytest
2301_8184190142 分钟前
C++中的状态模式实战
开发语言·c++·算法
独隅1 小时前
Python 标准库 (Standard Library) 全面使用指南
android·开发语言·python
yuzhuanhei1 小时前
C++进阶(上)
开发语言·c++