php 作曲家警告:缺少 openssl 扩展。如何在 WAMP 中启用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14062055/
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 06:32:56  来源:igfitidea点击:

Composer Warning: openssl extension is missing. How to enable in WAMP

phpwampservercomposer-php

提问by sleeper

Trying to install Composerdependency management tool on Win7/64 + WampServer 2.2via the Setup Installerand I am getting the following message:

尝试通过安装安装程序Win7/64 + WampServer 2.2上安装Composer依赖管理工具,我收到以下消息:

The openssl extension is missing, which will reduce the security and stability of Composer. If possible you should enable it or recompile php with --with-openssl

缺少 openssl 扩展,会降低 Composer 的安全性和稳定性。如果可能,您应该启用它或使用 --with-openssl 重新编译 php

So here is what I did...

所以这就是我所做的......

  1. From my Wamp icon in Tray, clicked php > php extensions > php_openssl
  2. This showed that task was completed by placing a check markbeside the extension
  3. I then restarted WampServer
  4. Then from the Wamp icon in tray, I clicked php > php.iniand searched for openssl to verifiy it was NOT commented) out. It was not.
  5. I then went back to Composer-Setup.exe and tried again. Same Warning Message: "openssl extension is missing"
  6. Having neverworked with OpenSSL, I'm not sure what is supposed to be set, so I tried to browse to one of my local sites using https. It Failed.
  1. 从托盘中的我的 Wamp 图标,单击 php > php extensions > php_openssl
  2. 这表明通过在扩展旁边放置复选标记来完成任务
  3. 然后我重新启动了 WampServer
  4. 然后从托盘中的 Wamp 图标,我点击php > php.ini并搜索 openssl 以验证它没有被注释)。不是。
  5. 然后我回到 Composer-Setup.exe 并再次尝试。相同的警告消息:“缺少 openssl 扩展”
  6. 从未与OpenSSL的工作,我不知道什么是应该设置,所以我试图使用HTTPS浏览到我的本地网站之一。它失败了。

What am I missing?

我错过了什么?

Please advise.

请指教。

回答by Valery I.

WAMP uses different php.ini files in the CLI and for Apache. when you enable php_openssl through the WAMP UI, you enable it for Apache, not for the CLI. You need to modify C:\wamp\bin\php\php-5.4.3\php.ini to enable it for the CLI.

WAMP 在 CLI 和 Apache 中使用不同的 php.ini 文件。当您通过 WAMP UI 启用 php_openssl 时,您是为 Apache 而不是 CLI 启用它。您需要修改 C:\wamp\bin\php\php-5.4.3\php.ini 来为 CLI 启用它。

回答by Scott Pigeon

In addition to uncommenting the ;extension=php_openssl.dllline in php.inithat everyone else has mentioned, you also have to ensure the ;extension_dir = "ext"line is also uncommented. To uncomment, remove the prefixed semicolon and save.

除了取消对;extension=php_openssl.dll符合php.ini其他人都已经提到的,你还必须确保;extension_dir = "ext"线也注释。要取消注释,请删除前缀分号并保存。

That line might already be uncommented in packages like WAMP and XAMPP, but it's not in a plain PHP download for Windows, so it's worth verifying. Also, you have to create the php.inifile by copying one of the examples, like php.ini-developmentto a new file and then name it php.ini. Then make these changes there.

该行可能已经在 WAMP 和 XAMPP 等包中取消注释,但它不在 Windows 的普通 PHP 下载中,因此值得验证。此外,您必须php.ini通过复制其中一个示例来创建文件,例如复制php.ini-development到一个新文件,然后将其命名为php.ini. 然后在那里进行这些更改。

Also, in the future, to install tools such as PHP and Composer, I recommend using the Chocolatey package manager. Then it's as simple as choco install composer. Of course, you'd still need to edit php.ini before installing Composer with the choco method. In future versions of Windows, package management tools like Chocolatey will be baked into Windows, the same way apt-getis in Ubuntu. Exciting times ahead for developers!

此外,将来要安装 PHP 和 Composer 等工具,我建议使用 Chocolatey 包管理器。那么就这么简单choco install composer。当然,在使用 choco 方法安装 Composer 之前,您仍然需要编辑 php.ini。在未来的 Windows 版本中,像 Chocolatey 这样的包管理工具将被烘焙到 Windows 中apt-get在 Ubuntu 中也是如此。对于开发人员来说,激动人心的时刻即将到来!

With either method, after installing Composer, don't forget to restart your terminal. Whether you're using Command Prompt, Bash (installs with Git), or Powershell, you'll need to restart it before the updated environmental variables work.

无论使用哪种方法,安装 Composer 后,不要忘记重新启动终端。无论您使用的是命令提示符、Bash(使用 Git 安装)还是 Powershell,您都需要在更新的环境变量起作用之前重新启动它。

回答by regularmike

I had the same problem even though openssl was enabled. The issue was that the Composer installer was looking at this config file:

即使启用了 openssl,我也遇到了同样的问题。问题是 Composer 安装程序正在查看此配置文件:

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

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

But the config file that's loaded is actually here:

但是加载的配置文件实际上在这里:

C:\wamp\bin\apache\apache2.2.22\bin\php.ini

C:\wamp\bin\apache\apache2.2.22\bin\php.ini

So I just had to uncomment it in the first php.ini file and that did the trick. This is how WAMP was installed on my machine by default. I didn't go changing anything, so this will probably happen to others as well. This is basically the same as Augie Gardner's answer above, but I just wanted to point out that you might have two php.ini files.

所以我只需要在第一个 php.ini 文件中取消注释它就可以了。这就是 WAMP 默认安装在我机器上的方式。我没有去改变任何东西,所以这可能也会发生在其他人身上。这与上面 Augie Gardner 的回答基本相同,但我只是想指出您可能有两个 php.ini 文件。

回答by vuhung3990

uncomment ;extension=php_openssl.dllin both

;extension=php_openssl.dll两者都取消注释

wamp\bin\php\php5.4.12\php.ini
wamp\bin\apache\Apache2.4.4\bin\php.ini

it will work

它会工作

回答by voltronluis

C:\laravel-master>composer create-project laravel/laravel Installing laravel/laravel (v4.0.6) - Installing laravel/laravel (v4.0.6) [RuntimeException] You must enable the openssl extension to download files via https

C:\laravel-master>composer create-project laravel/laravel 安装laravel/laravel (v4.0.6) - 安装laravel/laravel (v4.0.6) [RuntimeException] 您必须启用openssl 扩展才能通过https 下载文件

I'm using EasyPhp (WAMP type). In the EasyPHP Icon in the taskbar, right click and select configuration then select PHP. I will open the PHP.inifile configuration in a Notepad, search-find or CTRL+Fin notepad for the word OPENSSLyou will find this ;extension=php_openssl.dlljust remove the ; and the extension=php_openssl.dllis active.

我正在使用 EasyPhp(WAMP 类型)。在任务栏中的 EasyPHP 图标中,右键单击并选择配置,然后选择 PHP。我将PHP.ini在记事本中打开文件配置,在记事本中 search-find 或CTRL+F中的单词OPENSSL你会发现这;extension=php_openssl.dll只是删除; 并且extension=php_openssl.dll是活跃的。

C:\laravel-master>composer create-project laravel/laravel Installing laravel/laravel (v4.0.6) - Installing laravel/laravel (v4.0.6) Downloading: 100% Created project in C:\laravel-master\laravel Loading composer repositories with package information Installing dependencies (including require-dev)

C:\laravel-master>composer create-project laravel/laravel 安装 laravel/laravel (v4.0.6) - 安装 laravel/laravel (v4.0.6) 下载:100% 在 C:\laravel-master\laravel 创建项目加载 composer包含包信息的存储库 安装依赖项(包括 require-dev)

回答by Zemba Albert

you need to edit the "c:\Program Files\wamp\bin\php\php5.3.13\php.ini" file search for: ;extension=php_openssl.dll

您需要编辑“c:\Program Files\wamp\bin\php\php5.3.13\php.ini”文件搜索:;extension=php_openssl.dll

remove the semicolon at the beginning

去掉开头的分号

note: if saving the file doesn't work then you need to edit it as administrator. (on win7) go to start menu, search for notepad, right-click on notepad, click "Run As Administrator"

注意:如果保存文件不起作用,那么您需要以管理员身份进行编辑。(在win7上)转到开始菜单,搜索记事本,右键单击记事本,单击“以管理员身份运行”

in the composer installation windows just click back then next (or close it and start again) and it should work

在作曲家安装窗口中,只需单击后退然后下一步(或关闭它并重新开始),它应该可以工作

回答by Njoroge Mathu

opened wamp/bin/apache/apache2.4.4/bin/php config.. wamp/bin/php/php5.4.16/php conf settings, php-ini production, php-ini dev, phpForApache find extension=php_openssl.dlland uncomment by removing ;

打开 wamp/bin/apache/apache2.4.4/bin/php config.. wamp/bin/php/php5.4.16/php conf 设置,php-ini 制作,php-ini dev,phpForApache find extension=php_openssl.dll并取消注释通过删除;

回答by Augie Gardner

Short and sweet, uncomment this line in wamp/bin/php/php5.3.13(or whatever php version):
;extension=php_openssl.dll(remove the ;)
Now run the command line installation of Composer. You won't have an error.
Good to go!

简短而甜蜜,在wamp/bin/php/php5.3.13(或任何 php 版本)中取消注释这一行:(
;extension=php_openssl.dll删除;
现在运行 Composer 的命令行安装。你不会有错误。
好去!

回答by Alex Pliutau

You should make a symlink to php.ini. Sorry for russian link.

您应该创建一个指向 php.ini 的符号链接。抱歉提供俄文链接

回答by Sujeet Kumar

Yes, you must have to open php.ini and remove the semicolon to:

是的,您必须打开 php.ini 并删除分号:

;extension=php_openssl.dll

remove the ";" like this and it will work.

去除那个 ”;” 像这样,它会起作用。

extension=php_openssl.dll

Happy Coding.

快乐编码。