3

I am trying to compile PHP 7.2.5 on a RedHat operation system. I already compiled OpenSSL 1.1.0h on my own in a directory of my own /home/user/openssl-1.1. These are the lines how I compiled OpenSSL

TARGET_DIR=/home/usr/openssl-1.1
# ...
./config no-shared --prefix=${TARGET_DIR} --openssldir=${TARGET_DIR}/conf
make INSTALL_PREFIX=${TARGET_DIR}
make install

Now, I want to compile PHP 7.2.5 together with the compiled OpenSSL version. I do it with these lines:

PHP_PREFIX=/home/user/php-7.2
export OPENSSL_INCLUDE_DIR=/home/user/openssl-1.1/include/openssl
# ...
./buildconf --force
./configure --prefix="$PHP_PREFIX" \
        --enable-sockets \
        --enable-embed \
        --enable-com-dotnet \
        --enable-ctype \
        --with-curl \
        --enable-mbstring=static \
        --with-gd \
        --enable-soap \
        --enable-pdo=static \
        --with-mp \
        --with-curl=static \
        --with-openssl=static \
        --with-openssl-dir="/home/user/openssl-1.1"

But at some point, I get this error message:

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

This file evp.h exists in the directory /home/user/openssl-1.1/include/openssl.

Does anyone know how to fix this problem?

4

2 回答 2

1

我用 PHP 7.2 和 7.4 测试过

如果您以非标准前缀安装软件,请考虑调整 PKG_CONFIG_PATH 环境变量,将其指向 OpenSSL 的 pkgconfig 目录。

程序:

  1. 安装 OpenSSL
wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
tar xzf /root/tmp/openssl/openssl-1.1.1i.tar.gz
cd openssl-1.1.1i
./Configure --prefix=/opt/openssl-1.1.1i/bin -fPIC -shared linux-x86_64
make -j 8 
make install

  1. 导出变量 PKG_CONFIG_PATH 以指向 pkgconfig 目录
export PKG_CONFIG_PATH=/opt/openssl-1.1.1i/bin/lib/pkgconfig

  1. 编译并安装 PHP。
tar xzf php-7.4.13.tar.gz
cd  php-7.4.13

./configure --prefix=/opt/php-7.4.13 --with-curl --enable-exif \
 --with-mhash --enable-mbstring --with-mysqli --enable-mysqlnd \
--with-zlib --with-bz2 --enable-fpm --with-pear -enable-gd\
--with-apxs2=/opt/httpd-2.4.46/bin/apxs - --with-webp \
 --with-jpeg --with-xpm --with-freetype --enable-intl \
--disable-ipv6 --with-pgsql --without-sqlite3 --without-pdo-sqlite \
 --disable-cgi --enable-soap --without-imap --without-imap-ssl \
--with-openssl=/opt/openssl-1.1.1i/bin \
--with-openssl-dir=/opt/openssl-1.1.1i/bin

make -j 8 
make install

  1. 测试 OpenSSL 版本
/opt/php-7.4.13/bin/php -i | grep -i openssl


OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.1.1i  8 Dec 2020
OpenSSL Header Version => OpenSSL 1.1.1i  8 Dec 2020
Openssl default config => /opt/openssl-1.1.1i/bin/ssl/openssl.cnf


于 2020-12-13T03:11:44.690 回答
0

我找到了解决--with-openssl问题的方法:必须将两个参数更改为--with-libdir如下所示:

./buildconf --force
./configure --prefix="$PHP_PREFIX" \
# ...
    --with-openssl=/home/user/openssl-1.1 \
    --with-libdir=lib64

据我所知,这里不需要其他环境变量。

于 2018-05-01T20:48:55.740 回答