简体   繁体   English

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

[英]How to enable PHP's openssl extension to install Composer?

I am trying to install Laravel in WAMP setup.我正在尝试在 WAMP 设置中安装 Laravel。 I am getting a warning message for not enabling openssl which I had already done in WAMP.我收到一条警告消息,提示我没有启用我已经在 WAMP 中完成的openssl

Here is a screenshot of the message.这是该消息的屏幕截图。

在此处输入图片说明

It is possible that WAMP and Composer are using different PHP installations. WAMP 和 Composer 可能使用不同的 PHP 安装。 Composer will use the PHP set in the PATH environment variable. Composer 将使用PATH环境变量中设置的 PHP。

If you want to enable the openssl extension 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.打开命令提示符,输入: echo %PATH%然后检查 PHP 安装的位置。
  2. Go to that location and edit the file named: php.ini .转到该位置并编辑名为: php.ini
  3. Uncomment the line extension=php_openssl.dll by removing the semicolon at the beginning.通过删除开头的分号取消注释extension=php_openssl.dll行。

Now you are good to install Composer.现在您可以安装 Composer。

I solved my problem a different way.我以不同的方式解决了我的问题。 The problem is that wamp's GUI was misleading: it claimed that I had php_openssl enabled.. and if I clicked on php.ini on the same GUI.. it actually showed that extension=php_openssl.dll was uncommented..问题是 wamp 的 GUI 具有误导性:它声称我启用了php_openssl .. 如果我在同一个 GUI 上单击php.ini .. 它实际上表明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.exe that 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 (这基本上确保没有人试图将作曲家应用于错误的 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.12 and looking php.in there.. when I opened it I was shocked that the line extension=php_openssl.dll was actually commented!我解决这个问题的方法是让自己进入 wamp 包中的 php 安装: C:\\wamp\\bin\\php\\php5.4.12并在那里查看php.in .. 当我打开它时,我惊讶于行extension=php_openssl.dll居然被评论了! I uncommented it and it worked just fine.我取消了它的注释,它工作得很好。

在此处输入图片说明

I had the same problem and here the solution I found, on your php.ini you need to do some changes:我遇到了同样的问题,这里是我找到的解决方案,在你的php.ini 上你需要做一些改变:

  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 中,您也需要激活扩展目录。

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

If you're doing this on Windows without one of the WAMP stacks, here's how to get this going如果您在没有WAMP 堆栈之一的 Windows 上执行此操作,请按以下步骤操作

  1. Download an installation of PHP for Windows .下载适用于 Windows 的 PHP 安装 Generally you'll want a non-thread safe install.通常你会想要一个非线程安全的安装。 You can use 32-bit or 64-bit builds您可以使用 32 位或 64 位版本
  2. Extract the zip file somewhere.将 zip 文件解压缩到某处。 I would suggest C:\\php .我建议C:\\php Composer's installer found it there without any additional prompting Composer 的安装程序在没有任何额外提示的情况下在那里找到了它
  3. The latest versions of PHP for Windows do not come with a php.ini by default .默认情况下,适用于 Windows 的最新版本的 PHP不附带php.ini Instead, you'll see two files, as noted below.相反,您将看到两个文件,如下所述。 Rename one to php.ini or copy it into php.ini .将其中一个重命名为php.ini或将其复制到php.ini
    • php.ini-development php.ini-开发
    • php.ini-production php.ini 制作
  4. Open your php.ini file 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)打开您的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 安装程序应该从这里完成您需要的所有其他操作。

You need to enable "extension=php_openssl.dll" in both files (php and apache).您需要在两个文件(php 和 apache)中启用“extension=php_openssl.dll”。 my pc files path are these :我的电脑文件路径是这些:

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

This is an old question but I just had the same issue (with PHP7) and the solution was, in the end, pretty simple.这是一个老问题,但我遇到了同样的问题(使用 PHP7),最终的解决方案非常简单。 Uncommenting the line in php.ini as per the other answers wasn't quite enough though.但是,根据其他答案取消注释php.ini的行还不够。 I needed to change it from:我需要改变它:

;extension=php_openssl.dll

to:到:

extension=ext/php_openssl.dll

Note the ext prefix.请注意ext前缀。 The dll already existed but was in a subfolder. dll 已经存在,但位于子文件夹中。 After changing the config the composer installer was happy.更改配置后,composer 安装程序很高兴。

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.搜索 openssl “你的 ctrl + F ”就可以了。
  3. there is a semi-colon before the openssl extension openssl 扩展名前有一个分号

    ;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.保存文件并重新启动您的 WAMP 服务器,然后您就可以开始了。 re-install the application again that should work.再次重新安装应该可以工作的应用程序。

There are two php.ini files, one for development and one for production.有两个php.ini文件,一个用于开发,一个用于生产。 Leave those, there is another php.ini file for configuration settings just above them with a gear like icon edit that.留下那些,还有另一个php.ini文件用于配置设置,就在它们上面,带有像图标编辑这样的齿轮。

After editting the "right" files (all php.ini's).编辑“正确”文件(所有 php.ini 文件)后。 i had still the issue.我仍然有这个问题。 My solution was:我的解决方案是:

  1. Adding a System variable: OPENSSL_CONF添加系统变量:OPENSSL_CONF

    the value of OPENSSL_CONF should be the openssl.cnf file of your current php version. 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

I faced the same problem, but when i was lokking for php.ini and php.exe i found php.exe at C:\\UwAmp\\bin\\php\\php-5.4.15 when php.ini at C:\\UwAmp\\bin\\apache.我遇到了同样的问题,但是当我查找 php.ini 和 php.exe 时,我发现 php.exe 位于 C:\\UwAmp\\bin\\php\\php-5.4.15,而 php.ini 位于 C:\\UwAmp\\bin \\阿帕奇。 I just copy php.ini at C:\\UwAmp\\bin\\php\\php-5.4.15 and Uncomment the line extension=php_openssl.dll and it fixed.我只是将 php.ini 复制到 C:\\UwAmp\\bin\\php\\php-5.4.15 并取消注释 extension=php_openssl.dll 行并修复它。

I am using WAMP server.我正在使用 WAMP 服务器。 Actually its files showed that openssl is opened.实际上它的文件显示openssl已打开。 But manually I went to the folder and edited php.ini .但手动我去了文件夹并编辑了php.ini Then I found it has not opened openssl.I uncommented it and it worked after after WAMP restart.然后我发现它没有打开openssl。我取消了它的注释,在WAMP重启后它可以工作。

C:\\wamp\\bin\\php\\php5.3.13 C:\\wamp\\bin\\php\\php5.3.13

Browse to the line that reads:浏览到以下行:

;extension=php_openssl.dll

and remove the semicolon preceding the line.并删除该行前面的分号。 Restart your WAMP server services (click in your icon tray > 'Restart All Services'重新启动您的 WAMP 服务器服务(单击您的图标托盘 >“重新启动所有服务”

If you still cannot solve your problem have a look at this.如果您仍然无法解决您的问题,请查看此内容。 This might be the solution you are looking for这可能是您正在寻找的解决方案

There are several php.ini files in C:\\wamp\\bin\\php\\php xyz folder. C:\\wamp\\bin\\php\\php xyz 文件夹中有几个 php.ini 文件。 You may find production, development and some other php.ini files.您可能会找到生产、开发和其他一些 php.ini 文件。 No point of editing production and development files.无需编辑生产和开发文件。 Find the file which is exactly as same as the below image.找到与下图完全相同的文件。 (You can find it. Just type php.ini in your search bar and do a search). (你可以找到它。只需在搜索栏中输入 php.ini 并进行搜索)。 Open the file and remove ;打开文件并删除; from extension=php_openssl.dll.来自扩展名=php_openssl.dll。 Save the file and close it.保存文件并关闭它。 Restart all services in Wampp server.重新启动 Wampp 服务器中的所有服务。 Re-install your composer.重新安装你的作曲家。

That is it.这就对了。

在此处输入图片说明

Wamp works with another php.ini that is in C:\\wamp\\bin\\apache\\Apache2.4.4\\bin\\php.ini. Wamp 与 C:\\wamp\\bin\\apache\\Apache2.4.4\\bin\\php.ini 中的另一个 php.ini 一起使用。 So you need to manualy find the correct file, that is in C:\\wamp\\bin\\php\\php5.4.12\\php.ini.所以你需要手动找到正确的文件,即 C:\\wamp\\bin\\php\\php5.4.12\\php.ini。 Uncomment the extension=php_openssl.dll line and just try to install Composer again.取消对 extension=php_openssl.dll 行的注释,然后再次尝试安装 Composer。

For those who're having the same problem as I was.对于那些和我有同样问题的人。 After doing all the solutions above, still didn't work for me.完成上述所有解决方案后,仍然对我不起作用。 I found out that, uWamp was creating the PHP.INI file in bin/apache directory.我发现,uWamp 正在 bin/apache 目录中创建 PHP.INI 文件。 So I had to copy the PHP.INI file into php installation directory, that is, bin/php/phpXXXX directory.所以只好把PHP.INI文件拷贝到php安装目录下,也就是bin/php/phpXXXX目录下。 This should also be where the php.exe is that you selected from the composer setup.这也应该是您从 Composer 设置中选择的 php.exe 所在的位置。

Hope this helps.希望这可以帮助。

If you compiled from source, then adding extension=php_openssl.dll to the php.ini file may not work .如果您从源代码编译,则将extension=php_openssl.dll添加到 php.ini 文件可能不起作用

To troubleshoot this, open a command prompt and type php -i .要解决此问题,请打开命令提示符并键入php -i Scroll up to the first line, it will tell you the most recent error regarding your php.ini file.向上滚动到第一行,它会告诉您有关 php.ini 文件的最新错误。

To solve the issue, find the php_openssl.dll file, for me it was in the very same directory of the compilation output: C:\\php-sdk\\bin\\phpdev\\vc14\\x64\\php-7.0.13-src\\x64\\Release_TS So just add the directory where the extension is, to the php.ini :为了解决这个问题,找到php_openssl.dll文件,对我来说它在编译输出的同一个目录中: C:\\php-sdk\\bin\\phpdev\\vc14\\x64\\php-7.0.13-src\\x64\\Release_TS所以只需将扩展所在的目录添加到php.ini

extension_dir = "C:\php-sdk\bin\phpdev\vc14\x64\php-7.0.13-src\x64\Release_TS"

Hopefully the error will be gone希望错误会消失

如果您使用的是 xampp 。返回到您在安装开始时选择要使用的命令行 php 的位置,然后选择包含 xampp 文件夹的路径。之后,如果您的安装程序说您有重复的 'extension= php_openssl.dll' 用“;”注释 php ini 中的一个 ssl 文件,您的安装应该可以顺利运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM