简体   繁体   English

如何使用 Apache Server 2.4 在 PHP 7.4 中启用 openSSL?

[英]How to enable openSSL in PHP 7.4 with Apache Server 2.4?

I am aware very similar questions have been around but none seem to have the solution for my problem.我知道非常相似的问题已经存在,但似乎没有一个可以解决我的问题。 I wonder if you could give me a hand with this one.我想知道你是否可以帮我解决这个问题。 I'll try to be as specific as possible:我会尽量具体:

  • I'm on a Windows x64我在 Windows x64
  • PHP version 7.4.6 PHP 版本 7.4.6
  • Apache server 2.4.43 Apache 服务器 2.4.43
  • On the php.ini file I uncommented extension=openssl and extension_dir = "ext"在 php.ini 文件中,我取消注释 extension=openssl 和 extension_dir = "ext"
  • On the httpd.conf file I added this extra snippet在 httpd.conf 文件中,我添加了这个额外的片段
<IfModule php7_module>
  AddHandler application/x-httpd-php .php
  PHPIniDir "C:/php-7.4.6"
  LoadFile "C:/php-7.4.6/libcrypto-1_1-x64.dll"
  LoadFile "C:/php-7.4.6/libssl-1_1-x64.dll"
  LoadFile "C:/php-7.4.6/libssh2.dll"
  LoadFile "C:/php-7.4.6/nghttp2.dll"
  LoadFile "C:/php-7.4.6/php7ts.dll"
</IfModule>

(I include the LoadFiles as I saw somewhere that that might be solution, well it's not for me at least) (我在某处看到了可能是解决方案的 LoadFiles,至少它不适合我)

  • Checked on the command line the modules installed (php -m) and it seems that the ssl module is enabled.在命令行上检查了安装的模块(php -m),似乎启用了 ssl 模块。 However when checking with the extension_loaded ('openssl') instruction it returns a false.但是,当使用 extension_loaded ('openssl') 指令检查时,它会返回 false。 Also, with phpinfo() I see that OpenSSL support is disabled and I should install (ext/openssl).此外,使用 phpinfo() 我看到 OpenSSL 支持被禁用,我应该安装(ext/openssl)。 I don't know why they are telling me opposite things.我不知道他们为什么要告诉我相反的事情。 https wrapper is not enabled either. https 包装器也未启用。
  • I checked if both php and apache were reading from different php.ini files and they both say the same thing: Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\php-7.4.6\php.ini I checked if both php and apache were reading from different php.ini files and they both say the same thing: Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\php-7.4.6\php.ini

Which btw I understand little, as there is no php.ini in the Windows folder.顺便说一句,我不太了解,因为 Windows 文件夹中没有 php.ini 。 I understand that the file is got from the path specified below.我了解该文件是从下面指定的路径中获取的。

  • In the ext folder there is the php_openssl.dll file.在 ext 文件夹中有 php_openssl.dll 文件。
  • I tried to include C:\php-7.4.6\libcrypto-1_1-x64.dll as environmental variable as I saw that in a different link.我试图将 C:\php-7.4.6\libcrypto-1_1-x64.dll 作为环境变量包括在内,因为我在不同的链接中看到了这一点。
  • And yes, I restarted the server several times.是的,我多次重新启动服务器。 I reckon I ran out of options and I don't know what else I should do.我想我已经没有选择了,我不知道我还能做什么。 Thanks for your help, I try to attach the links that I've been visiting.感谢您的帮助,我尝试附上我一直在访问的链接。 although I'm sure I'm leaving some behind as I lost track.虽然我确信我会因为迷路而留下一些东西。

Unable to find the wrapper "https" with file_get_contents 无法使用 file_get_contents 找到包装器“https”

OpenSSL Support disabled in Apache 2.4/PHP 7.4.4 OpenSSL 支持在 Apache 2.4/PHP 7.4.4 中禁用

PHP OpenSSL extension not working while install Typo3 6.2.2 on window7 PHP OpenSSL 扩展在 window7 上安装 Typo3 6.2.2 时不起作用

How to enable HTTPS stream wrappers 如何启用 HTTPS stream 包装器

Thanks a lot!非常感谢!

Fortunately I managed to get it to work and I want to share with you all the solution in case you are facing the same problem.幸运的是,我设法让它工作,我想与你分享所有的解决方案,以防你遇到同样的问题。 I happened to think about checking the error logs of Apache and the following error was registered for every module: Unable to load dynamic library.我碰巧想到检查Apache的错误日志,每个模块都注册了以下错误:无法加载动态库。 It was trying to take the module from the /ext folder, which it didn't know where it was, so what I did was to change in the php.ini file the extension_dir to an absolute PATH "C:\php-7.4.6\ext" and now it works like a dream!它试图从 /ext 文件夹中获取模块,但它不知道它在哪里,所以我所做的是将 php.ini 文件中的 extension_dir 更改为绝对路径“C:\php-7.4. 6\ext",现在它像梦一样工作!

There is a line in php.ini: php.ini 中有一行:

;extension_dir = "ext"

You just have to uncomment it in addition to uncomment extension=php_openssl.dll as well.除了取消注释extension=php_openssl.dll之外,您只需取消注释它。

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

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