简体   繁体   English

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

[英]OpenSSL Support disabled in Apache 2.4/PHP 7.4.4

I'm trying to setup Apache MariaDB PHP manually but I'm running into some issues with the openssl feature.我正在尝试手动设置 Apache MariaDB PHP 但我遇到了 Z50935Z5D4B201A6761 功能的一些问题。 Here are the steps I took to setup Apache 2.4 and PHP 7.4.4:以下是我设置 Apache 2.4 和 PHP 7.4.4 的步骤:

I. Apache httpd Installation and configuration一、Apache httpd安装配置

  1. Download and Extract httpd-2.4.43-win64-VS16.zip from apachelounge to "D:\Programs-64Bit\Apache24"从 apachelounge 下载httpd-2.4.43-win64-VS16.zip并解压到“D:\Programs-64Bit\Apache24”
  2. Set ServerRoot in httpd.conf with full path在 httpd.conf 中使用完整路径设置ServerRoot
  3. Set ServerName to localhost:80ServerName设置为localhost:80
  4. Define WWWROOT with desired DocumentRoot path in httpd.conf (ie Define WWWROOT "E:/Programs/WWW" )在 httpd.conf 中使用所需的 DocumentRoot 路径定义 WWWROOT(即 Define WWWROOT Define WWWROOT "E:/Programs/WWW"
  5. Set DocumentRoot and <Directory> values to "${WWWROOT}"DocumentRoot<Directory>值设置为"${WWWROOT}"

II.二、 Combining PHP with apache结合 PHP 与 apache

  1. Download and Extract Thread Safe php-7.4.4-Win32-vc15-x64.zip to "D:\Programs-64Bit\PHP\PHP7.4.4-64Bit"下载并解压线程安全的 php-7.4.4-Win32-vc15-x64.zip到“D:\Programs-64Bit\PHP\PHP7.4.4-64Bit”
  2. Add the following lines at the end of httpd.conf:在 httpd.conf 的末尾添加以下行:
 Define PHPROOT "D:/Programs-64Bit/PHP/PHP7.4.4-64Bit" LoadModule php7_module "${PHPROOT}/php7apache2_4.dll" AddType application/x-httpd-php.php PHPIniDir "${PHPROOT}" LoadFile "${PHPROOT}/libcrypto-1_1-x64.dll" LoadFile "${PHPROOT}/libssl-1_1-x64.dll" LoadFile "${PHPROOT}/libssh2.dll" LoadFile "${PHPROOT}/nghttp2.dll" LoadFile "${PHPROOT}/php7ts.dll"
  1. Copy and rename php.ini-development to the same php root directory as php.ini将 php.ini-development 复制并重命名为与 php.ini 相同的 php 根目录
  2. set extension_dir and enable every single extension except oci8_12c, pdo_firebird, pdo_oci and snmp设置 extension_dir 并启用除 oci8_12c、pdo_firebird、pdo_oci 和 snmp 之外的每个扩展

III.三、 Testing PHP with Apache使用 Apache 测试 PHP

  1. Create a php file (index.php) with the following code:使用以下代码创建 php 文件 (index.php):
 <?php phpinfo(); ?>
  1. run httpd.exe运行 httpd.exe

This is what it tells me about openssl:这就是它告诉我关于 openssl 的信息:

显示 phpinfo 的 phar 部分的图像。 openssl 支持被禁用

according to " OpenSSL support disabled in Apache/PHP on Windows " on StackOverflow and the last comment in the php.net page " PHP Manual > Function Reference > Cryptography Extensions > OpenSSL > Installing/Configuring " it should be working. according to " OpenSSL support disabled in Apache/PHP on Windows " on StackOverflow and the last comment in the php.net page " PHP Manual > Function Reference > Cryptography Extensions > OpenSSL > Installing/Configuring " it should be working. what am I doing wrong?我究竟做错了什么?

If you'd like to enable OpenSSL suport in Phar .如果您想在Phar中启用OpenSSL支持。
Just uncomment following line.只需取消注释以下行。

// php.ini
extension=openssl

This is actually easy to solve.这其实很容易解决。 after checking if openssl was enable on PHP in a command prompt with the command php index.php where index.php is the file created in the original post. after checking if openssl was enable on PHP in a command prompt with the command php index.php where index.php is the file created in the original post. One can see that openssl is actually enable.可以看到 openssl 实际上是启用的。

To enable it on Apache2.4, one needs to uncomment LoadModule ssl_module modules/mod_ssl.so in httpd.conf.要在 Apache2.4 上启用它,需要在 httpd.conf 中取消注释LoadModule ssl_module modules/mod_ssl.so

The phar section will look like this: phar 部分将如下所示:

显示启用 openssl 支持的 phpinfo 的 Phar 部分的图像

And an openssl section will appear:并且将出现 openssl 部分:

显示仅在启用 openssl 时可见的 openssl 部分的图像

In case anyone's extension=openssl and LoadModule ssl_module modules/mod_ssl.so are both uncommented and still looking for answers, try setting your extension_dir to absolute path;如果任何人的extension=opensslLoadModule ssl_module modules/mod_ssl.so注释并且仍在寻找答案,请尝试将您的extension_dir设置为绝对路径; extension_dir = "C:\php\ext" . extension_dir = "C:\php\ext"

I've been searching around for hours and that solved it.我一直在寻找几个小时,这解决了它。 Thanks to Koichi's answer .感谢Koichi的回答 Also I didn't need any of those LoadFile lines my httpd.conf .我的httpd.conf也不需要任何这些LoadFile行。


My environment (for any reference):我的环境(供任何参考):

  • Windows Server 2019 Datacenter Windows 服务器 2019 数据中心
  • PHP Version 7.4.13 PHP 版本 7.4.13
  • Apache/2.4.46 (Win64) OpenSSL/1.1.1i (from Apache Haus ) Apache/2.4.46 (Win64) OpenSSL/1.1.1i (来自Apache Haus )

I spent a long time on this problem too and tried the suggested methods (uncommenting line, absolute not relative path).我也在这个问题上花了很长时间,并尝试了建议的方法(取消注释行,绝对不是相对路径)。 What finally worked was installing PHP into "C:\php" and updating the PHP module settings in Apache's httpd.conf, rather than having it in some other path.最终奏效的是将 PHP 安装到“C:\php”并更新 Apache 的 httpd.conf 中的 PHP 模块设置,而不是将其放在其他路径中。 It feels like there's an Apache problem somewhere, as it working perfectly fine when PHP was installed in my initial non-standard path and served by another web server.感觉好像在某处存在 Apache 问题,因为当 PHP 安装在我的初始非标准路径中并由另一个 web 服务器提供服务时,它工作得非常好。

If you have PHP installed somewhere else and are able to move it to C:\php and adjust Apache's settings, it's worth trying.如果您在其他地方安装了 PHP 并且能够将其移动到 C:\php 并调整 Apache 的设置,那么值得一试。

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

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