When attempting to compile PHP 5.4.6 from source on Ubuntu, many developers encounter the frustrating error:
configure: error: Cannot find OpenSSL's <evp.h>
Even when explicitly specifying the OpenSSL path with --with-openssl=/usr/include/openssl
, the error persists. This typically occurs because Ubuntu separates OpenSSL development headers into a separate package.
Before compiling PHP 5.4.6, ensure you have all required dependencies:
sudo apt-get update
sudo apt-get install build-essential libxml2-dev \
libssl-dev libcurl4-openssl-dev libjpeg-dev \
libpng-dev libmcrypt-dev libreadline-dev
The critical package here is libssl-dev
, which provides the OpenSSL development headers including evp.h
.
Here's the complete process to compile PHP 5.4.6:
wget http://us1.php.net/get/php-5.4.6.tar.gz/from/this/mirror -O php-5.4.6.tar.gz
tar -xzvf php-5.4.6.tar.gz
cd php-5.4.6
./configure --with-openssl --prefix=/usr/local/php5.4.6 \
--with-mysql --with-mysqli --with-pdo-mysql \
--with-zlib --enable-mbstring --with-curl
make
sudo make install
Instead of compiling from source, consider using Ondřej Surý's PPA which maintains updated PHP versions:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.4
This method automatically handles all dependencies and configuration.
If you still encounter OpenSSL issues, verify the header location:
sudo find / -name evp.h
Then explicitly reference it in your configure command:
./configure --with-openssl=/usr/include/openssl \
--with-openssl-dir=/usr/include/openssl \
--prefix=/usr/local/php5.4.6
Remember to clean your build directory between attempts:
make clean
make distclean
html
When attempting to compile PHP 5.4.6 from source on Ubuntu, many developers encounter the frustrating OpenSSL header error:
configure: error: Cannot find OpenSSL's <evp.h>
This occurs even when explicitly specifying the OpenSSL path with --with-openssl=/usr/include/openssl
during configuration.
First, ensure all development dependencies are installed:
sudo apt-get update
sudo apt-get install build-essential \
libxml2-dev \
libssl-dev \
libcurl4-openssl-dev \
libjpeg-dev \
libpng-dev \
libmcrypt-dev
The key solution lies in correctly pointing to OpenSSL's development headers. Try this configure command:
./configure \
--prefix=/usr/local/php5.4.6 \
--with-openssl \
--with-openssl-dir=/usr/include/openssl \
--with-config-file-path=/etc/php5.4.6 \
[other your configuration options]
For those preferring package management, consider adding Ondřej Surý's PPA:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.4
After successful installation, verify with:
php -v
php -m | grep openssl
You should see PHP 5.4.6 version information and OpenSSL module listed.
If issues persist:
- Check actual OpenSSL header location:
find /usr -name evp.h
- Clean previous build attempts:
make clean
- Ensure symbolic links are correct:
ls -l /usr/include/openssl