通过Composer安装erusev/parsedown时发生Curl 59错误

问题遇到的现象和发生背景

我最近搭建一个博客网站,需要使用PHP编写的Markdown解析器用于解析我的博客。我相中了erusev/parsedown这个PHP包,但是在尝试使用composer安装时出现了curl 59错误,在网上找了好久都没找到解决方案。

操作环境、软件版本等信息

该网站配置的是宝塔的Nginx,使用PHP 8.0,已经配置SSL,使用的是宝塔提供的Let's encrypt证书。
PHP配置如下:

[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile=/etc/ssl/certs/ca-certificates.crt

; If openssl.cafile is not specified or if the CA file is not found, the
; directory pointed to by openssl.capath is searched for a suitable
; certificate. This value must be a correctly hashed certificate directory.
; Most users should not specify a value for this directive as PHP will
; attempt to use the OS-managed cert stores in its absence. If specified,
; this value may still be overridden on a per-stream basis via the "capath"
; SSL stream context option.
;openssl.capath=
openssl.default_socket_timeout=60

nginx配置如下:

#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    ssl_certificate    /www/server/panel/vhost/cert/www.peterho.top/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/www.peterho.top/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3>    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;
#SSL-END

详细的错误信息:

curl error 59 while downloading https://repo.packagist.org/packages.json: failed setting cipher list: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH

img

尝试过的解决方法

目前已经尝试过换源、重新启动服务等方法,但均无效。在网上也没有找到任何的解决方案。@

我想要达到的结果

希望解决Curl 59错误并成功安装erusev/parsedown

针对你的问题结合chatgpt知识库请参考以下内容:
针对解决 "curl error 59 while downloading https://repo.packagist.org/packages.json: failed setting cipher list: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH" 错误的详细步骤:

  1. 编辑服务器上的 /etc/php.ini 文件,并在其末尾添加以下内容:
openssl_conf = openssl_init
[openssl_init]
default_conf = default_sect
 
[default_sect]
ssl_conf = ssl_sect
 
[ssl_sect]
system_default = system_default_sect
 
[system_default_sect]
Options = TLSv1.2

将这个配置保存并退出文件。

  1. 确认 OpenSSL 版本是否支持 TLSv1.2。您可以通过运行以下命令来检查 OpenSSL 版本:
openssl version

确保 OpenSSL 版本为 1.0.1 或更高版本。

  1. 重新启动 PHP-FPM 和 Nginx。您可以使用以下命令来完成此操作:
sudo service php8.0-fpm restart
sudo service nginx restart
  1. 接下来,再次运行您之前尝试安装 erusev/parsedown 的 composer 命令,如:
composer require erusev/parsedown

此时,Composer 应该可以下载和安装 erusev/parsedown 库了。

如果您遇到任何问题,请确保查看 PHP 错误日志,并查看所报告的任何错误。还可以尝试升级到最新版本的 OpenSSL 库以解决问题。

1换镜像方法:

 composer config -g repo.packagist composer https://packagist.phpcomposer.com

二、本地开启了代理工具
Git bash 设置代理

export http_proxy=http://127.0.0.1:7890  // 代理地址均为http,地址和端口看代理软件
export https_proxy=http://127.0.0.1:7890  // 代理地址均为http,地址和端口看代理软件
```bash


移除用这个

unset http_proxy
unset https_proxy
Powershell设置代理
$Env:http_proxy="http://127.0.0.1:7890"
$Env:https_proxy="http://127.0.0.1:7890"
移除代理值设为空即可



```

I