OpenSSL 启用但不工作 [英] OpenSSL enabled but not working

查看:27
本文介绍了OpenSSL 启用但不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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

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

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.

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

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.

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

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

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

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

$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);

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

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.

推荐答案

文档说明 (引用你已经引用的内容) :

注意:为什么这个函数可能不存在
ftp_ssl_connect() 只是如果 ftp 模块和构建了 OpenSSL 支持静态进入 php,这意味着在 Windows 上,此功能将是在官方 PHP 版本中未定义.
使此功能可用在 Windows 上你必须自己编译PHP 二进制文件.

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.

您说您手动"安装了 PHP;但这可能仍然意味着您使用了来自 php.net 的官方"构建——这意味着您还没有编译自己的 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...


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...

这里有一些关于此的文档:在 Windows 上构建您自己的 PHP -- 但是...祝你好运...我从来没有听说过在 Windows 上编译 PHP 是简单的",实际上 (在 Linux 上没有那么难,但在编译方面 Linux 可能更适合一些)

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)


其他几个解决方案:


A couple of other solutions :

  • 为您的开发切换到 Linux (即使它只使用虚拟机) -- 但您可能仍然需要重新编译 PHP 才能获得它(默认情况下可能未启用)
  • 只是不使用该功能;毕竟,您知道您的托管服务是否会为您提供吗?(如果您不能在生产服务器上使用它,则无需在您的开发/测试机上使用)
  • 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)

这篇关于OpenSSL 启用但不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆