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'

相关推荐
鹏仔先生11 小时前
拷贝漫画APP下载页PHP程序,后台带免费AI写作
php
LDR00614 小时前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术14 小时前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript
码云数智-园园14 小时前
C++20 Modules 模块详解
java·开发语言·spring
swordbob15 小时前
NIO的channel中什么是 fd(File Descriptor,文件描述符)
java·开发语言·nio
AI创界者15 小时前
PilotTTS 一键整合包(Win/Mac):8G 显存畅跑,实测解锁情绪与副语言的精准控制
人工智能·macos·aigc·音视频
源分享15 小时前
Java线程同步的多种实现方法(非常详细)
java·开发语言·jvm
Luminous.15 小时前
C语言--day30
c语言·开发语言
何以解忧,唯有..16 小时前
Go语言循环语句详解:for、range与循环控制
开发语言·算法·golang
謓泽16 小时前
C语言不是语法,是通往机器的地图。
c语言·开发语言