php 在 XAMPP 中启用 OpenSSL

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

Enabling the OpenSSL in XAMPP

phpsslxampp

提问by Mert MET?N

I spent three hours but I did not find anything; I'm unable to connect to a SSL enabled server. I want to list what i did:

我花了三个小时,但没有找到任何东西;我无法连接到启用 SSL 的服务器。我想列出我所做的:

First checked my PHP extensions directory was in order; extension wasn't there, php_openssl.dll

首先检查我的PHP扩展目录是否有序;扩展名不存在,php_openssl.dll

Then I opened my php.inifile but I could not see any extension=php_openssl.dllline to uncomment.

然后我打开了我的php.ini文件,但我看不到任何extension=php_openssl.dll行来取消注释。

Also, I searched on Google and saw people with the same problem. http://www.apachefriends.org/f/viewtopic.php?p=162623

另外,我在谷歌上搜索,看到有同样问题的人。 http://www.apachefriends.org/f/viewtopic.php?p=162623

However, I also have

不过,我也有

OPENSSL_CONF C:/xampp/apache/bin/openssl.cnf 
...
openssl
OpenSSL support enabled 
OpenSSL Library Version OpenSSL 0.9.8l 5 Nov 2009 
OpenSSL Header Version OpenSSL 0.9.8l 5 Nov 2009

no lines . What should I do? Please share your suggestions.

没有线。我该怎么办?请分享您的建议。

回答by Memochipan

Yes, you must open php.iniand remove the semicolon to:

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

;extension=php_openssl.dll

If you don't have that line, check that you have the file (In my PC is on D:\xampp\php\ext) and add this to php.iniin the "Dynamic Extensions" section:

如果您没有该行,请检查您是否拥有该文件(在我的 PC 上D:\xampp\php\ext)并将其添加到php.ini“动态扩展”部分:

extension=php_openssl.dll

回答by Mert MET?N

[PHP_OPENSSL]
extension=php_openssl.dll

This is the answer.

这就是答案。

回答by macio.Jun

I use xampp. Beforehand I tried the example file "test_smtp_gmail_basic.php" in phpMailer (you can download phpMailer here: https://github.com/Synchro/PHPMailer), but I got the following error:

我使用 xampp。事先我在 phpMailer 中尝试了示例文件“test_smtp_gmail_basic.php”(您可以在此处下载 phpMailer:https: //github.com/Synchro/PHPMailer),但出现以下错误:

Mailer Error: The following From address failed: [email protected]

邮件程序错误:以下发件人地址失败:[email protected]

After I commented out ; extension=php_openssl.dllin php.ini, it is working now.

在我; extension=php_openssl.dll在 php.ini 中注释掉之后,它现在可以工作了。

回答by sameer.nuna

In xampp, if "extension=php_openssl.dll" is not present in your php.ini file then add it in the "Windows Extensions" section of your php.ini file and restart your apache. It works for me..

在 xampp 中,如果 php.ini 文件中不存在“extension=php_openssl.dll”,则将其添加到 php.ini 文件的“Windows 扩展”部分并重新启动 apache。这个对我有用..

回答by Roni davelman

You will need to edit your php.ini. It's 4 easy steps.

您将需要编辑您的 php.ini。这是4个简单的步骤。

Find your php.ini file.

找到您的 php.ini 文件。

$inipath = php_ini_loaded_file();

Enable openssl in the file:

在文件中启用openssl:

extension=php_openssl.dll 

Turn allow_url_fopen on

打开allow_url_fopen

allow_url_fopen = On

Restart apache and you are done!

重新启动 apache,你就完成了!

回答by shazyriver

Things have changed for PHP > 7. This is what i had to do for PHP 7.2.

PHP > 7 的情况发生了变化。这就是我必须为 PHP 7.2 做的事情。

Step: 1:Uncomment extension=openssl

步骤:1:取消注释extension=openssl

Step: 2:Uncomment extension_dir = "ext"

步骤:2:取消注释extension_dir = "ext"

Step: 3:Restart xampp.

步骤:3:重启xampp。

Done.

完毕。

Explanation: ( From php.ini )

说明:(来自 php.ini )

If you wish to have an extension loaded automatically, use the following syntax:

如果您希望自动加载扩展,请使用以下语法:

extension=modulename

Note :The syntax used in previous PHP versions (extension=<ext>.soand extension='php_<ext>.dll) is supported for legacy reasons and may be deprecated in a future PHP major version. So, when it is possible, please move to the new (extension=<ext>) syntax.

注意:以前的 PHP 版本(extension=<ext>.soextension='php_<ext>.dll)中使用的语法由于遗留原因受到支持,并且可能会在未来的 PHP 主要版本中被弃用。因此,如果可能,请移至新的 ( extension=<ext>) 语法。

Special Note:Be sure to appropriately set the extension_dirdirective.

特别注意:一定要适当地设置extension_dir指令。

回答by Rudy Lister

I am assuming that this question is for those using a windows based system.

我假设这个问题是针对那些使用基于 Windows 的系统的。

After making sure that the extension extension=php_openssl.dll in your php.ini file does not have a semicolon.

确保 php.ini 文件中的 extension=php_openssl.dll 没有分号后。

Then make sure that you have added C:/xampp/apache/bin into your environment path in order to use openssl without having move the command prompt to that directory C:/xampp/apache/bin

然后确保您已将 C:/xampp/apache/bin 添加到您的环境路径中,以便使用 openssl 而无需将命令提示符移动到该目录 C:/xampp/apache/bin

回答by BurninLeo

So, what did we do to make openssl_pkey_new()and all the other openssl_functions in PHP work...

那么,我们做了什么使PHP 中的openssl_pkey_new()所有其他openssl_函数都能工作......

  • Enabled the extension php_openssl.dllin the (right/active) php.ini. Checked.
  • Checked that there exists a openssl.cnfin xampp\apache\conf\(and also in two other directories within XAMPP). Checked.
  • Added the environment variable OPENSSL_CONFin the Windows system settings with the full path to the above openssl.cnf. Checked.
  • Restarted Apache (and after that did not work restarted the computer several times...). Checked.
  • php_openssl.dll在 (right/active) 中启用扩展php.ini。检查。
  • 检查是否存在openssl.cnfin xampp\apache\conf\(以及 XAMPP 中的其他两个目录)。检查。
  • OPENSSL_CONF在 Windows 系统设置中添加了环境变量以及上面的完整路径openssl.cnf。检查。
  • 重新启动Apache(之后没有工作重新启动计算机几次......)。检查。

Still does not work, and throwing errors such as

仍然不起作用,并抛出诸如

  • error:0E06D06C:configuration file routines:NCONF_get_string:no value
  • error:02001002:system library:fopen:No such file or directory
  • error:2006D080:BIO routines:BIO_new_file:no such file
  • 错误:0E06D06C:配置文件例程:NCONF_get_string:无值
  • 错误:02001002:系统库:fopen:没有那个文件或目录
  • 错误:2006D080:BIO 例程:BIO_new_file:没有这样的文件


Okay, here are another two more things to check.

好的,这里还有另外两件事要检查。

1. Trouble with the environment

1.环境问题

Run php_info()from a PHP script, and go to the "Apache Environment" section. Check the value of OPENSSL_CONF.

php_info()从 PHP 脚本运行,然后转到“Apache 环境”部分。检查 的值OPENSSL_CONF

Surprise. This is not what we have set in the windows system settings.

惊喜。这不是我们在windows系统设置中设置的。

The solution is simple. Set the environment variable in the PHP script.

解决方法很简单。在 PHP 脚本中设置环境变量。

putenv('OPENSSL_CONF=C:\xampp\apache\conf\openssl.cnf');

2. Trouble with relative filenames

2. 相对文件名问题

Now, openssl_pkey_new()will work, but openssl_pkey_export_to_file()does still not work and returns falsewithout any further explanation?

现在,openssl_pkey_new()会起作用,但openssl_pkey_export_to_file()仍然不起作用并返回false而没有任何进一步的解释?

Check the filename that you have specified as output filename. It will not work in Windows as long as you do not specify the full path.

检查您指定为输出文件名的文件名。只要您不指定完整路径,它就不会在 Windows 中工作。

$folder = realpath('../keyring');
$outfile = $folder.'/private.pem';
openssl_pkey_export_to_file($key, $outfile);

回答by mpalencia

STEP 1: On your php.inicomment out ;extension=php_openssl.dll

第 1 步:关于您的php.ini评论;extension=php_openssl.dll

STEP 2: Copy libeay32.dll and ssleay32.dll from your PHP root folder and paste it your Apache/bin folder

第 2 步:从 PHP 根文件夹复制 libeay32.dll 和 ssleay32.dll 并将其粘贴到 Apache/bin 文件夹

STEP 3: Restart Apache

第 3 步:重新启动 Apache