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'

相关推荐
景熙552311 分钟前
15.Java 8 Stream 流入门到实战
java·开发语言·数据结构
黑化旺仔2 小时前
【OC】KVO
macos·ios·objective-c·cocoa
Bruce_Liuxiaowei3 小时前
Python 实例赋值遮蔽类属性:一个从不报错的静默陷阱
开发语言·python·语法糖
aramae4 小时前
MySQL内置函数(7)
开发语言·笔记·后端·mysql·其他
szephyr5 小时前
HTTPS 证书申请与自动续期:acme.sh + Let‘s Encrypt 完整记录
nginx·https·acme.sh·证书续期
辛迪聊物业数字化5 小时前
智慧物业管理平台架构实践:从SaaS物业云到商管系统的全模块落地
大数据·微服务·php
码行山野赴时序归途7 小时前
链表家族收官篇:循环链表
c语言·开发语言·数据结构·链表
景熙55237 小时前
单体项目编写思路和落地形式
java·开发语言
计算机毕设定制辅导-无忧学长8 小时前
《基于SpringBoot的未成年人健康知识科普平台的设计与实现》
java·开发语言·vue.js·spring boot·未成年人健康知识科普平台
Ivanqhz8 小时前
Ping-Pong 双缓冲
开发语言·人工智能·python·深度学习·mlir