apache OpenSSL 启用但不工作

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

OpenSSL enabled but not working

phpapachesslftpopenssl

提问by mitch

I am running Apache 2.2.13 and PHP 5.2.12. Just installed PHP 5.2.12 manually (to have access to all extensions) and enabled OpenSSL. phpinfo() indicates OpenSSL is enabled and running OpenSSL 0.9.8k 25 Mar 2009.

我正在运行 Apache 2.2.13 和 PHP 5.2.12。刚刚手动安装了 PHP 5.2.12(以访问所有扩展)并启用了 OpenSSL。phpinfo() 表示 OpenSSL 已启用并运行 OpenSSL 0.9.8k 2009 年 3 月 25 日。

I'm getting this error: PHP Fatal error: Call to undefined function ftp_ssl_connect().

我收到此错误:PHP 致命错误:调用未定义的函数 ftp_ssl_connect()。

I've seen where the PHP manual suggests 'ftp_ssl_connect() is only available if both the ftp module and the OpenSSL support is built statically into php' and further states that 'you must compile your own PHP binaries' to make it work with Windows.

我已经看到 PHP 手册建议“ftp_ssl_connect() 仅在 ftp 模块和 OpenSSL 支持静态构建到 php 中时才可用”的地方,并进一步指出“您必须编译自己的 PHP 二进制文件”以使其适用于 Windows .

I have the suspicion that phpinfo() only indicates OpenSSL as being 'enabled' because I have uncommented the line 'extension=php_openssl.dll' and have the correct dlls in the correct folders and the correct path in the environment variables. And perhaps a static build into PHP must be accomplished regardless of what phpinfo() indicates.

我怀疑 phpinfo() 仅将 OpenSSL 指示为“已启用”,因为我取消了“extension=php_openssl.dll”行的注释,并且在正确的文件夹中具有正确的 dll,在环境变量中具有正确的路径。也许无论 phpinfo() 指示什么,都必须完成对 PHP 的静态构建。

I believe the objective of distribution (as described above) is for dynamic extensions, but recompiling (for OpenSSL) is to encode a static extension.

我相信分发的目标(如上所述)是针对动态扩展,但重新编译(针对 OpenSSL)是对静态扩展进行编码。

ftp extension is working fine (built into PHP 5.2). I test this with the following code:

ftp 扩展工作正常(内置于 PHP 5.2)。我使用以下代码对此进行测试:

$conn_id = ftp_connect($url); $login_result = ftp_login($conn_id, $username, $password); ftp_close($conn_id);

$conn_id = ftp_connect($url); $login_result = ftp_login($conn_id, $username, $password); ftp_close($conn_id);

Note that to check ssl, I only change ftp_connect to ftp_ssl_connect. When reaching this line, I get the PHP error above in my Apache error log file.

请注意,为了检查 ssl,我只将 ftp_connect 更改为 ftp_ssl_connect。到达这一行时,我在 Apache 错误日志文件中收到上述 PHP 错误。

回答by Pascal MARTIN

As the documentation states(quoting what you already quoted):

正如文档所述(引用您已经引用的内容)

Note: Why this function may not exist
ftp_ssl_connect()is only available if both the ftp module and the OpenSSL support is built statically into php, this means that on Windows this function will be undefined in the official PHP builds.
To make this function available on Windows you must compile your own PHP binaries.

注意:为什么此函数可能不存在
ftp_ssl_connect()仅在 ftp 模块和 OpenSSL 支持静态构建到 php 中时才可用,这意味着在 Windows 上,此函数将在官方 PHP 构建中未定义。
要在 Windows 上使用此功能,您必须编译自己的 PHP 二进制文件。

You say you installed PHP "manually" ; but this probably still means you used an "official" build from php.net -- which means you have not compiled your own PHP binaries... So, that function is not available.

您说您“手动”安装了 PHP;但这可能仍然意味着您使用了来自 php.net 的“官方”构建——这意味着您还没有编译自己的 PHP 二进制文件......因此,该功能不可用。


There is no magic : it seems you'll have to re-compile PHP, using the right configuration options at compile-time, if you want to be able to use that function...


没有什么神奇之处:如果您希望能够使用该功能,似乎您必须在编译时使用正确的配置选项重新编译 PHP...

Here's some documentation about that : Build your own PHP on Windows-- but... good luck... i've never heard it was "simple" to compile PHP on windows, actually (it's not that hard on Linux, but Linux is maybe a bit more well suited when it comes to compilation)

这里有一些关于这个的文档:在 Windows 上构建你自己的 PHP——但是......祝你好运......我从来没有听说过在 Windows 上编译 PHP 是“简单的”,实际上(它在 Linux 上并不难,但在 Linux 上并不难)在编译方面可能更适合)


A couple of other solutions :


其他几个解决方案:

  • switching to Linux for your developments (even if it's only using a Virtual Machine)-- but you might still have to recompile PHP to get that (might not be enabled by default)
  • just not using that function ; after all, do you know if your hosting service will provide you with it ? (If you can't use it on your production server, no need to use on your development/testing machine)
  • 为您的开发切换到 Linux (即使它只使用虚拟机)——但您可能仍然需要重新编译 PHP 才能获得它(默认情况下可能未启用)
  • 只是不使用该功能;毕竟,您知道您的托管服务是否会为您提供吗?(如果你不能在你的生产服务器上使用它,就不需要在你的开发/测试机上使用)