如何解决`configure: error: Cannot find OpenSSL's <evp.h>`?

Cap*_*ppY 36 php openssl

我试图重新编译 PHP,但 ./configure 在以下位置失败:

configure: error: Cannot find OpenSSL's <evp.h>
Run Code Online (Sandbox Code Playgroud)

我安装了 LibSSL 1.0.0、LibSSL 0.9.8、LibSSL-Dev、OpenSSL。

--with-openssl=/usr/include/openssl
Run Code Online (Sandbox Code Playgroud)

当我尝试

--with-openssl
Run Code Online (Sandbox Code Playgroud)

告诉我:

配置:错误:找不到 OpenSSL 的库

**** 问题出在哪里?

PS Php 是 5.2.5,操作系统是 Ubuntu

小智 50

发生了同样的问题,Ubuntu 12.04.1 LTS并通过发出以下命令解决了:

sudo apt-get install libcurl4-openssl-dev pkg-config

  • `libcurl4-openssl-dev` 与 `libssl-dev` 有何不同? (4认同)

Jin*_*nKo 18

要在 Debian wheezy 上构建 php-5.3,您需要以下内容来修复此错误。

apt-get install libssl-dev libsslcommon2-dev
Run Code Online (Sandbox Code Playgroud)

然后您需要使用以下内容进行配置

./configure --with-libdir=/lib/x86_64-linux-gnu ...
Run Code Online (Sandbox Code Playgroud)

  • 1+,对我帮助很大。我还必须添加`--with-php-config /usr/local/src/php-xxx/scripts/php_config`。我写了一个[如何编译带有扩展的 PHP。](http://blog.flowl.info/2015/compile-php-5-6-pthreads-mongo-ubuntu/?utm_source=serverfault) (2认同)

sym*_*ean 12

假设您已经拥有 OpenSSL 库和头文件(在 rpm 系统上,后者位于 xxxx-devel 包中)...

该问题似乎源于如何configure解决分布在文件系统周围的依赖项。为了编译代码,编译器需要知道头文件在哪里。要链接代码,链接器需要知道库的位置。

[colin@host]$ configure .... --with-openssl-dir=/usr/include/openssl ....
...
checking OpenSSL dir for FTP... /usr/include/openssl
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>

[colin@host]$ find /usr/include -name evp.h
/usr/include/openssl/evp.h
Run Code Online (Sandbox Code Playgroud)

include 目录有包含文件,但 pkg-config 失败,因为库不在/usr/include/openssl 中,它在 /usr/lib 中

使用 /usr 作为目录再次运行配置:

configure .... --with-openssl-dir=/usr ....
...
checking OpenSSL dir for FTP... /usr
checking for pkg-config... /usr/bin/pkg-config
checking for OpenSSL version... >= 0.9.6
checking for CRYPTO_free in -lcrypto... yes
...
Run Code Online (Sandbox Code Playgroud)

搜索作为参数传递的路径以查找相关资源。


小智 11

要在 debian 8.1 (Jessie) 上编译 php-5.4.45,我必须:

apt-get install libssl-dev
Run Code Online (Sandbox Code Playgroud)

之后我可以编译它只是使用 --with-openssl


小智 10

另一个./configure可能失败的原因是你没有pkg-config安装,就像我的 PHP7 和 Debian Jessie 一样:

sudo apt-get install pkg-config
Run Code Online (Sandbox Code Playgroud)

  • 与三年前不同的答案中已经指出了这一点。 (2认同)