新的服务器,用了宝塔,在PHP7.3中却没有zip扩展。于是想到用pecl进行安装:
> pecl install zip
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
Could not download from "https://pecl.php.net/get/zip-1.19.0.tgz", cannot download "pecl/zip" (Connection to `ssl://pecl.php.net:443' failed: )
Error: cannot download "pecl/zip"
Download failed
install failed
没想到安装失败。看到网上很多方法都是讲pecl上的扩展现在到本地,然后运行 pecl 进行本地安装。但是,仔细看看上面的报错,发现 ssl: xxxxxx faild,看来是https导致的问题。于是不断查资料,认证了自己的想法
php -r "print_r(openssl_get_cert_locations());"
Array
(
[default_cert_file] => /usr/local/openssl/cert.pem
[default_cert_file_env] => SSL_CERT_FILE
[default_cert_dir] => /usr/local/openssl/certs
[default_cert_dir_env] => SSL_CERT_DIR
[default_private_dir] => /usr/local/openssl/private
[default_default_cert_area] => /usr/local/openssl
[ini_cafile] => /etc/pki/tls/certs/ca-bundle.crt
[ini_capath] =>
)
其中certfile : /usr/local/openssl/cert.pem 并不存在,修复一下:
wget http://curl.haxx.se/ca/cacert.pem && mv cacert.pem /usr/local/openssl/cert.pem
再次运行 pecl install ,一切正常。