解决:安装composer时The openssl extension is missing, which means that secure HTTPS transfers are impossib

[root@localhost ~]# curl -sS https://getcomposer.org/installer | php


Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl

Linux下开启方法:

我的是centos7 服务器,PHP版本:7.2 以下为PHP添加openssl模块支持。 该方法是不需要重新编译PHP版本的。 如果服务器上存在PHP安装包文件最好,如果已经删除,去下载和phpinfo页面显示版本一样的PHP安装文件,我这里是 php-7.2.33.tar.gz 地址为: https://www.aliyundrive.com/s/uP5Ha5zbbpR (不支持分享),

可到github下载

https://github.com/MITZ1979/php72.git

下载后解压到/usr/local/php-7.2.33目录下

#进入/usr/local/目录
cd /usr/local/
#解压php-7.2.33.tar.gz包
tar zxvf php-7.2.33.tar.gz

 

进入PHP的openssl扩展模块目录

cd php-7.2.33/ext/openssl/
/usr/local/php/bin/phpize # 这里为你自己的phpize路径,如果找不到,使用whereis phpize查找

 

执行后,发现错误 无法找到config.m4 ,config0.m4就是config.m4。直接重命名

mv config0.m4 config.m4
/usr/local/php/bin/phpize
./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config
make
make install

 

安装完成后,会返回一个.so文件(openssl.so)的目录。在此目录下把openssl.so 文件拷贝到你在php.ini 中指定的 extension_dir 下(在php.ini文件中查找:extension_dir =),我这里的目录是 /usr/local/php/bin/phpize/lib/php/extensions/no-debug-zts-20170718/

编辑php.ini文件,在文件最后添加

extension=openssl.so

 

重启Apache即可

/usr/local/apache2/bin/apachectl restart

ok,成功添加openssl支持。

 

参考文章 https://www.wangjingxian.cn/qita/87.html 写。

 

posted @ 2022-03-17 00:31  狂奔的狼  阅读(528)  评论(0编辑  收藏  举报