如何启用 PHP 的 openssl 扩展来安装 Composer?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18064612/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:54:41  来源:igfitidea点击:

How to enable PHP's openssl extension to install Composer?

phpcomposer-phpphp-openssl

提问by FirmView

I am trying to install Laravel in WAMP setup. I am getting a warning message for not enabling opensslwhich I had already done in WAMP.

我正在尝试在 WAMP 设置中安装 Laravel。我收到一条警告消息,提示我没有启用我已经在 WAMP 中完成的openssl

Here is a screenshot of the message.

这是该消息的屏幕截图。

enter image description here

在此处输入图片说明

回答by Rubens Mariuzzo

It is possible that WAMP and Composer are using different PHP installations. Composer will use the PHP set in the PATHenvironment variable.

WAMP 和 Composer 可能使用不同的 PHP 安装。Composer 将使用PATH环境变量中设置的 PHP 。

If you want to enable the opensslextension to install Composer, first you need to check the location of the PHP installation.

如果要启用openssl扩展来安装Composer,首先需要检查 PHP 安装的位置。

  1. Open a Command Prompt, type: echo %PATH%then check for the location of your PHP installation.
  2. Go to that location and edit the file named: php.ini.
  3. Uncomment the line extension=php_openssl.dllby removing the semicolon at the beginning.
  1. 打开命令提示符,输入:echo %PATH%然后检查您的 PHP 安装位置。
  2. 转到该位置并编辑名为:php.ini.
  3. extension=php_openssl.dll通过删除开头的分号来取消注释该行。

Now you are good to install Composer.

现在您可以安装 Composer。

回答by abbood

I solved my problem a different way. The problem is that wamp's GUI was misleading: it claimed that I had php_opensslenabled.. and if I clicked on php.inion the same GUI.. it actually showed that extension=php_openssl.dllwas uncommented..

我以不同的方式解决了我的问题。问题是 wamp 的 GUI 具有误导性:它声称我已php_openssl启用.. 如果我单击php.ini同一个 GUI.. 它实际上显示extension=php_openssl.dll未注释..

I'm not sure if i'm using the same installer version of composer of the OP, but it actually asks you at the beginning to specify the php.exethat you like to apply composer on (which basically ensures that no one tries to apply composer to the wrong php executable as what happened with the OP)..

我不确定我是否使用了 OP 的 Composer 的相同安装程序版本,但它实际上在开始时要求您指定php.exe要应用 Composer 的对象(这基本上确保没有人尝试将 Composer 应用到错误的 php 可执行文件,就像 OP 发生的一样)。

The way I solved this was by going myself into the installation of php within the wamp package: C:\wamp\bin\php\php5.4.12and looking php.inthere.. when I opened it I was shocked that the line extension=php_openssl.dllwas actually commented! I uncommented it and it worked just fine.

我解决这个问题的方法是让自己进入 wamp 包中的 php 安装:C:\wamp\bin\php\php5.4.12并查看php.in那里..当我打开它时,我震惊地发现该行extension=php_openssl.dll实际上被评论了!我取消了它的注释,它工作得很好。

enter image description here

在此处输入图片说明

回答by Francisco Cabral

I had the same problem and here the solution I found, on your php.iniyou need to do some changes:

我遇到了同样的问题,这里是我找到的解决方案,在你的php.ini 上你需要做一些改变:

  1. extension_dir = "ext"
  2. extension = php_openssl.dll
  1. extension_dir = "ext"
  2. extension = php_openssl.dll

Every one here talks active the openssl extension, but in windows you need to active the extension dir too.

这里的每个人都在谈论激活 openssl 扩展,但在 Windows 中,您也需要激活扩展目录。

回答by user3887814

For WAMP server, comment given by "Enrique" solved my problem.

对于 WAMP 服务器,“Enrique”给出的评论解决了我的问题。

wamp is using this php.ini:

wamp 正在使用这个php.ini

c:\wamp\bin\apache\Apache2.4.4\bin\php.ini

But composer is using PHP from CLI, and hence it's reading this file:

但是 composer 正在从 CLI 使用 PHP,因此它正在读取这个文件:

c:\wamp\bin\php\php5.4.12\php.ini (so you need to enable openssl there)

For composer you will have to enable extension in

对于作曲家,您必须在

c:\wamp\bin\php\php5.4.12\php.ini

Change:

改变:

;extension=php_openssl.dll 

to

extension=php_openssl.dll

回答by Machavity

If you're doing this on Windows withoutone of the WAMP stacks, here's how to get this going

如果您在没有WAMP 堆栈之一的Windows 上执行此操作,请按以下步骤操作

  1. Download an installation of PHP for Windows. Generally you'll want a non-thread safe install. You can use 32-bit or 64-bit builds
  2. Extract the zip file somewhere. I would suggest C:\php. Composer's installer found it there without any additional prompting
  3. The latest versions of PHP for Windows do not come with a php.iniby default. Instead, you'll see two files, as noted below. Rename one to php.inior copy it into php.ini.
    • php.ini-development
    • php.ini-production
  4. Open your php.inifile and remove the semicolon from this line (you might want to uncomment other things as well but this line is the only one necessary for Composer)

    ;extension=php_openssl.dll
    
  1. 下载适用于 Windows 的 PHP 安装。通常你会想要一个非线程安全的安装。您可以使用 32 位或 64 位版本
  2. 将 zip 文件解压缩到某处。我会建议C:\php。Composer 的安装程序在没有任何额外提示的情况下在那里找到了它
  3. 默认情况下,适用于 Windows 的最新版本的 PHP不附带php.ini. 相反,您将看到两个文件,如下所述。将其中一个重命名为php.ini或将其复制到php.ini.
    • php.ini-开发
    • php.ini 制作
  4. 打开您的php.ini文件并从这一行中删除分号(您可能还想取消注释其他内容,但这一行是 Composer 唯一需要的)

    ;extension=php_openssl.dll
    

That should be all you need to do. The Composer installer should do everything else you need from here.

这应该是您需要做的全部。Composer 安装程序应该从这里完成您需要的所有其他操作。

回答by Mohammed Saqib Rajput

You need to enable "extension=php_openssl.dll" in both files (php and apache). my pc files path are these :

您需要在两个文件(php 和 apache)中启用“extension=php_openssl.dll”。我的电脑文件路径是这些:

  1. C:\wamp\bin\php\php5.3.13\php.ini
  2. C:\wamp\bin\apache\apache2.2.22\bin\php.ini
  1. C:\wamp\bin\php\php5.3.13\php.ini
  2. C:\wamp\bin\apache\apache2.2.22\bin\php.ini

回答by K Cartlidge

This is an old question but I just had the same issue (with PHP7) and the solution was, in the end, pretty simple. Uncommenting the line in php.inias per the other answers wasn't quite enough though. I needed to change it from:

这是一个老问题,但我遇到了同样的问题(使用 PHP7),最终的解决方案非常简单。但是,php.ini根据其他答案取消注释该行还不够。我需要改变它:

;extension=php_openssl.dll

to:

到:

extension=ext/php_openssl.dll

Note the extprefix. The dll already existed but was in a subfolder. After changing the config the composer installer was happy.

注意ext前缀。dll 已经存在,但位于子文件夹中。更改配置后,composer 安装程序很高兴。

回答by DLoneDeveloper

you need to enable the openssl extension in

您需要在中启用 openssl 扩展

C:\wamp\bin\php\php5.4.12\php.ini 

that is the php configuration file that has it type has "configuration settings" with a driver-notepad like icon.

那是具有它类型的php配置文件具有“配置设置”,带有一个驱动程序记事本图标。

  1. open it either with notepad or any editor,
  2. search for openssl "your ctrl + F " would do.
  3. there is a semi-colon before the openssl extension

    ;extension=php_openssl.dll
    

    remove the semi-colon and you'll have

    extension=php_openssl.dll
    
  4. save the file and restart your WAMP server after that you're good to go. re-install the application again that should work.
  1. 用记事本或任何编辑器打开它,
  2. 搜索 openssl “你的 ctrl + F ”就可以了。
  3. openssl 扩展名前有一个分号

    ;extension=php_openssl.dll
    

    删除分号,你就会有

    extension=php_openssl.dll
    
  4. 保存文件并重新启动您的 WAMP 服务器,然后您就可以开始了。再次重新安装应该可以工作的应用程序。

回答by keneth

There are two php.inifiles, one for development and one for production. Leave those, there is another php.inifile for configuration settings just above them with a gear like icon edit that.

有两个php.ini文件,一个用于开发,一个用于生产。留下这些,在php.ini它们上方还有另一个用于配置设置的文件,带有一个像图标编辑那样的齿轮。

回答by Mafu

After editting the "right" files (all php.ini's). i had still the issue. My solutionwas:

编辑“正确”文件(所有 php.ini 文件)后。我仍然有这个问题。我的解决方案是:

  1. Adding a System variable: OPENSSL_CONF

    the value of OPENSSL_CONF should be the openssl.cnf file of your current php version.

  1. 添加系统变量:OPENSSL_CONF

    OPENSSL_CONF 的值应该是您当前 php 版本的 openssl.cnf 文件。

for me it was:

对我来说是:

  • C:\wamp\bin\php\php5.6.12\extras\ssl\openssl.cnf
  • C:\wamp\bin\php\php5.6.12\extras\ssl\openssl.cnf

-> Restart WAMP -> should work now

-> 重新启动 WAMP -> 现在应该可以工作了

Source: http://php.net/manual/en/openssl.installation.php

来源:http: //php.net/manual/en/openssl.installation.php