37

Im trying to recompile PHP, but ./configure fails at :

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

I have LibSSL 1.0.0, LibSSL 0.9.8, LibSSL-Dev, OpenSSL installed.

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

when I try with

--with-openssl

tells me:

configure: error: Cannot find OpenSSL's libraries

Where the **** are the problem ?

P.S. Php is 5.2.5, OS is Ubuntu

10 Answers 10

50

The same issue occurred on Ubuntu 12.04.1 LTS and it was solved by issuing:

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

2
  • Hello :) I forgot how do I solve my problem. :) It was a half year ago.
    – CappY
    Mar 2, 2013 at 21:55
  • 4
    How is libcurl4-openssl-dev different from libssl-dev?
    – Gherman
    Aug 31, 2017 at 12:02
18

To build php-5.3 on Debian wheezy you need the following to fix this error.

apt-get install libssl-dev libsslcommon2-dev

Then you need to configure with the following included

./configure --with-libdir=/lib/x86_64-linux-gnu ...
3
  • 2
    1+, helped me a lot. I also had to add --with-php-config /usr/local/src/php-x.x.x/scripts/php_config. I have written a how-to compile PHP with extensions.
    – Daniel W.
    Feb 16, 2015 at 22:27
  • works but fails all test cases.
    – Rafael
    Jul 29, 2015 at 4:13
  • Works to for PHP5.2 manual compile on Ubuntu 14.04 with "--with-openssl" directive. thanks a lot.
    – Dr I
    Aug 3, 2015 at 14:54
13

Assuming that you already have the OpenSSL libraries and header files (on rpm systems the latter are in the xxxx-devel package)...

The issue seems to arise from how configure resolves dependencies which are distributed around the filesystem. To compile the code, the comiler needs to know where the headers are. To link the code, the linker needs to know where the libraries are.

[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

The include directory has the include file, but pkg-config fails because the library is not in /usr/include/openssl, its in /usr/lib

Running configure again with /usr as the directory:

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

The path passed as an argument is searched to find the relevant resources.

4
  • This worked for me. This is a good solution. Oct 15, 2015 at 5:50
  • This was solution on debian wheezy + php 5.3.10! Thank you!!!!
    – holms
    Mar 23, 2017 at 19:00
  • @holms: that's now a rather old version of php. Particularly if you're going to use compiled-from-source rather than managed packages, then you should use a recent release.
    – symcbean
    Mar 23, 2017 at 21:55
  • This was the solution for me building php-7.1.12 on Debian Jessie. Thank you
    – ako
    Nov 27, 2017 at 8:51
11

To compile php-5.4.45 on debian 8.1 (Jessie) i had to:

apt-get install libssl-dev

After that I could compile it just using --with-openssl

9

Another reason ./configure might fail is because you don't have pkg-config installed, like in my case with PHP7 and Debian Jessie:

sudo apt-get install pkg-config
1
  • 2
    That was already pointed out in a different answer from three years ago.
    – kasperd
    Nov 4, 2015 at 10:41
2

I fixed the issue by installing extra libraries

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
1

On centos7 Install openssl-devel yum install openssl-devel

0

You need to help configure figuring out where to look for the evp.h file, because by default it will scan for directories and add hardcoded suffixes to them to find it. I've kept the details in my wiki page for those who want to understand the solution. Here's what worked for me :

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 (paths are different). If that didn't work for you check the wiki page, it will help you figure out what paths to put.

0

I had the same problem on Fedora 19 despite having OpenSSL installed.

I had to install openssl-devel.i686 which I found by doing a generic search for all packages related to ssl:

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

Then I ran configure again with success:

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

Just my feedback: After solving this ssl problem from thsi post, I've completely give up on compiling php 5.3 because it's failed down futher on zend dom extensions in the middle, I've found some patches, and decided just to drop this fuss. There's ubuntu 12.04 which still has 5.3.10 php on board. Be careful php-fpm back then been clearing environment variables. So don't be surprised when you can't pass global variables from docker for example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .