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'

相关推荐
彦为君12 小时前
Java文件处理效率库Commons-IO(速览)
java·开发语言·mfc
sycmancia13 小时前
Qt——文本打印与光标定位
开发语言·qt
故事和你9113 小时前
洛谷-【动态规划1】动态规划的引入2
开发语言·数据结构·c++·算法·动态规划·图论
AI人工智能+电脑小能手13 小时前
【大白话说Java面试题 第71题】【Mysql篇】第1题:索引是什么?
java·开发语言·b树·mysql·面试
九皇叔叔14 小时前
VMware 安装 麒麟操作系统
java·开发语言·虚拟机·麒麟操作系统·vmware安装
weixin1997010801614 小时前
[特殊字符] 人工抓取数据革命:从“人肉爬虫”到“智能数据工厂”全面转型指南
开发语言·爬虫·python
一行代码一行诗++14 小时前
goto语句
java·开发语言·算法
froginwe1114 小时前
JSP 日期处理
开发语言
imuliuliang15 小时前
Laravel 1.x:框架传奇的起点
php·laravel
楷哥爱开发15 小时前
演唱会自动化抢票如何提高成功率?票务住宅IP与配置指南
服务器·前端·php