Home > linux > php > phpconfig > phpevp.h | About

TL;DR

You've just run configure and you find yourself with this situation

root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # ./configure 
[...]
checking for DSA_get_default_method in -lssl... yes
checking for X509_free in -lcrypto... yes
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # 

Yet a quick search shows that evp.h is really there

root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # locate evp.h
/usr/include/openssl/evp.h
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # head /usr/include/openssl/evp.h
/* crypto/evp/evp.h */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
 * All rights reserved.
 *
 * This package is an SSL implementation written
 * by Eric Young (eay@cryptsoft.com).
 * The implementation was written so as to conform with Netscapes SSL.
 * 
 * This library is free for commercial and non-commercial use as long as
 * the following conditions are aheared to.  The following conditions
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd #

So how does configure not see it ? the reason is because the configure file needs help figuring out where to look for it, and here's what you can do. But first, let me explain how I came with the quick fix : You have to figure out how configure is trying to look for that file. So I opened up configure in my favorite editor and eventually found this :

     1      for i in $PHP_OPENSSL_DIR; do
     2        if test -r $i/include/openssl/evp.h; then
     3          OPENSSL_INCDIR=$i/include
     4        fi
     5        if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
     6          OPENSSL_LIBDIR=$i/$PHP_LIBDIR
     7        fi
     8        test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
     9      done
       
    10      if test -z "$OPENSSL_INCDIR"; then
    11        as_fn_error $? "Cannot find OpenSSL's <evp.h>" "$LINENO" 5
    12      fi
       
    13      if test -z "$OPENSSL_LIBDIR"; then
    14        as_fn_error $? "Cannot find OpenSSL's libraries" "$LINENO" 5
    15      fi

This shows that configure uses such variables as PHP_OPENSSL_DIR to search for evp.h. If you edit that file and echo the PHP_OPENSSL_DIR variable you will see that it misses "/usr", which is where it should be looking at (giving that /include is hardcoded in line 3. So the solution is to simply define this variable as an environement variable, export it, then run configure again :

root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # PHP_OPENSSL_DIR="/usr" 
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # export PHP_OPENSSL_DIR
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # ./configure
[...]
checking for DSA_get_default_method in -lssl... yes
checking for X509_free in -lcrypto... yes
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's libraries
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # 

Aha ! no more evp.h error ! but we still have another error related to finding openssl's librariries. So using the same technique as earlier, I read the configure file and found that the same code I pasted above is responsible for finding OpenSSL's libs. I found out that the libs live in

root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # locate libssl.so
/usr/lib/x86_64-linux-gnu/libssl.so
/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0
root@audio-mon[10.10.10.82] ~/DOWNLOADS/php-5.5.23/ext/mysqlnd # 

So what I did is add this path to PHP_OPENSSL_DIR. But that wasn't enough, so I studied the code again and found that I also need to set the other variable called PHP_LIBDIR. This variable, though, isn't read from the environement, it is read from the arguments of the command line (the –with- args). You can infer this from this portion of the configure file :

# Check whether --with-libdir was given.
if test "${with_libdir+set}" = set; then :
  withval=$with_libdir; PHP_LIBDIR=$withval
else

So what I did is simply re-set PHP_OPENSSL_DIR to add the new path along with /usr and add a new argument –with-libdir="". If you don't put this by default PHP_LIB_DIR will be /lib and openssl's libraries won't be found because /lib will be appended to the paths.

TL;DR

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 # 

contact : @ychaouche yacinechaouche at yahoocom


QR Code
QR Code TL;DR (generated for current page)