如何解决configure:error:找不到OpenSSL的<evp.h>?

我试图重新编译PHP,但./configure失败:

configure: error: Cannot find OpenSSL's <evp.h> 

我已经安装了LibSSL 1.0.0,LibSSL 0.9.8,LibSSL-Dev,OpenSSL。

 --with-openssl=/usr/include/openssl 

当我尝试

 --with-openssl 

告诉我:

configuration:错误:找不到OpenSSL的库

****是哪里的问题?

PS Php是5.2.5,OS是Ubuntu

Ubuntu 12.04.1 LTS发生了同样的问题,并通过发布:

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

要在Debian上构buildphp-5.3,需要以下内容来解决这个错误。

  apt-get install libssl-dev libsslcommon2-dev 

那么你需要configuration以下内容

  ./configure --with-libdir=/lib/x86_64-linux-gnu ... 

另一个原因./configure可能会失败,因为你没有安装pkg-config ,就像在我的情况下使用PHP7和Debian Jessie:

sudo apt-get install pkg-config

假设你已经有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 

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

以/ usr作为目录再次运行configure:

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

作为parameter passing的path被search以find相关的资源。

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

 apt-get install libssl-dev 

之后,我可以使用--with-openssl来编译它

我通过安装额外的库来解决这个问题

 sudo apt-get install -y autoconf g++ make openssl libssl-dev libcurl4-openssl-dev sudo apt-get install -y libcurl4-openssl-dev pkg-config sudo apt-get install -y libsasl2-dev 

您需要帮助configuration找出在哪里寻找evp.h文件,因为默认情况下,它将扫描目录,并添加硬编码后缀find它。 我已经在我的wiki页面上保留了那些想要了解解决scheme的细节。 以下是对我有用的东西:

 root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # PHP_OPENSSL_DIR="/usr /usr/lib/x86_64-linux-gnu" root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # ./configure --with-libdir="" [...] checking for DSA_get_default_method in -lssl... yes checking for X509_free in -lcrypto... yes checking for pkg-config... /usr/bin/pkg-config checking for OpenSSL version... >= 0.9.6 # <------------------------------------- YES ! [...] config.status: creating config.h config.status: config.h is unchanged root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # 

YMMV(path不同)。 如果这不适合你检查维基页面 ,它将帮助你找出什么path。

尽pipe安装了OpenSSL,但在Fedora 19上也遇到同样的问题。

我不得不安装openssl-devel.i686,通过对所有与ssl相关的软件包进行通用search:

 sudo yum search ssl sudo yum install openssl-devel.i686 

然后我再次运行configuration成功:

 sudo ./configure --with-apxs2=/usr/bin/apxs --with-mysql --enable-mbstring --with-mysqli --with-openssl=/usr/ 

只是我的反馈:在解决这个ssl问题之后,我完全放弃了编译php 5.3,因为它在中间的zend dom扩展中失败了,我find了一些补丁,并决定放弃这个大惊小怪。 还有Ubuntu 12.04,它仍然有5.3.10的PHP上。 请注意php-fpm后来清除了环境variables。 所以当你不能从docker传递全局variables时,不要感到惊讶。