When compiling PHP from source (specifically version 5.2.5 in this case), the configure script failing to find OpenSSL headers is a common issue that can stem from several causes:
configure: error: Cannot find OpenSSL's <evp.h>
Even when you have multiple OpenSSL versions installed (like libssl1.0.0, libssl0.9.8, and openssl-dev packages), the compiler might still fail to locate the necessary headers.
First, let's verify what OpenSSL packages are actually installed:
dpkg -l | grep -i openssl
And check where the development headers are located:
find /usr -name "evp.h"
1. Install Missing Development Packages
For Ubuntu/Debian systems:
sudo apt-get install libssl-dev
2. Specify Correct OpenSSL Path
The most reliable solution is to explicitly tell configure where to find OpenSSL:
./configure --with-openssl=/usr \
--with-openssl-dir=/usr \
--with-openssl-inc=/usr/include/openssl
Alternatively, if you know the exact path:
./configure --with-openssl=/usr/local/ssl \
--with-openssl-dir=/usr/local/ssl
3. Symbolic Link Solution
Sometimes creating symlinks helps:
sudo ln -s /usr/include/openssl /usr/local/include/openssl
When you get the "Cannot find OpenSSL's libraries" error, try:
export LD_LIBRARY_PATH=/usr/local/ssl/lib:$LD_LIBRARY_PATH
./configure --with-openssl
Or check library locations with:
ldconfig -p | grep libssl
Here's a complete configure command that typically works:
LDFLAGS="-L/usr/local/ssl/lib" \
CPPFLAGS="-I/usr/local/ssl/include" \
./configure --with-openssl=/usr/local/ssl \
--with-openssl-dir=/usr/local/ssl \
--with-openssl-inc=/usr/local/ssl/include/openssl
Remember to adapt paths to match your system's OpenSSL installation.
When compiling PHP from source on Ubuntu, you might encounter the frustrating error:
configure: error: Cannot find OpenSSL's <evp.h>
or alternatively:
configure: error: Cannot find OpenSSL's libraries
This typically occurs when:
- OpenSSL development headers are missing
- The OpenSSL path specified is incorrect
- Multiple OpenSSL versions are installed causing conflicts
- 32-bit vs 64-bit library mismatch exists
First, ensure all required packages are installed:
sudo apt-get update
sudo apt-get install openssl libssl-dev
If you're still getting the error, try specifying the correct OpenSSL path:
./configure --with-openssl=/usr --other-php-options
For some systems, you might need to explicitly point to the include directory:
./configure --with-openssl-dir=/usr/include/openssl --other-php-options
If the issue persists, check where your OpenSSL files are actually located:
sudo find / -name evp.h
Then use the parent directory in your configure command. For example, if you find evp.h at /usr/local/ssl/include/openssl/evp.h
, use:
./configure --with-openssl=/usr/local/ssl --other-php-options
If you have multiple OpenSSL versions installed, you might need to:
sudo update-alternatives --config openssl
Then select the appropriate version before reconfiguring PHP.
After successful configuration, check the PHP configuration to verify OpenSSL support:
php -i | grep -i openssl
This should show OpenSSL support is enabled with the correct version.