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

admin2023-01-184479
在安装composer-setup.exe的时候遇到如下问题:
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
是说没有开启openssl,解决方法如下:
phpstudy开启方法:
php扩展及设置-》php扩展-》php_openssl
windows下开启方法:
1: 首先检查php.ini中;extension=php_openssl.dll是否存在, 如果存在的话去掉前面的注释符‘;’, 如果不存在这行,那么添加extension=php_openssl.dll。
2、复制php安装目录中的:
  libeay32.dll
  ssleay32.dll
  至c:\windows\system32
3、复制PHP\ext目录中的php_openssl.dll至c:\windows\system32
4: 重启apache或者iis
至此,openssl功能就开启了。
注意:如果以上都不行,那么看下
C:\wamp\bin\apache\Apache2.4.4\bin是否这个目录下有PHP.INI 也需要开启openssl
去掉extension=php_openssl.dll前面的;号。
Linux下开启方法:
我使用的是锦尚数据的云主机,PHP版本:5.2.14
下面方案就以我的主机为例讲解为PHP添加openssl模块支持。
网上一些答案说要重新编译PHP,添加configure参数,增加openssl的支持。这里讲一个不需要重新编译的方法。
如果服务器上存在PHP安装包文件最好,如果已经删除,去下载和phpinfo页面显示版本一样的PHP安装文件,我这里是 php-5.2.14.tar.gz
推荐去搜狐镜像下载,网易镜像没有找到。地址为: http://mirrors.sohu.com/php/
用ssh工具连接到主机。
# 下载到/var/www/php5目录下
cd /var/www/php5
# 解压
tar zxvf php-5.2.14.tar.gz
# 进入PHP的openssl扩展模块目录
cd php-5.2.14/ext/openssl/
/var/www/php5/bin/phpize # 这里为你自己的phpize路径,如果找不到,使用whereis phpize查找
# 执行后,发现错误 无法找到config.m4 ,config0.m4就是config.m4。直接重命名
mv config0.m4 config.m4
/var/www/php5/bin/phpize
./configure --with-openssl --with-php-config=/var/www/php5/bin/php-config
make
make install
# 安装完成后,会返回一个.so文件(openssl.so)的目录。在此目录下把openssl.so 文件拷贝到你在php.ini 中指定的 extension_dir 下(在php.ini文件中查找:extension_dir =),我这里的目录是 var/www/php5/lib/php/extensions
# 编辑php.ini文件,在文件最后添加
extension=openssl.so
# 重启Apache即可
/usr/local/apache2/bin/apachectl restart
好了,现在就成功添加openssl支持。


网友评论