用OpenSSL编译PHP7.2

用OpenSSL编译PHP7.2,php,compilation,openssl,php-7.2,Php,Compilation,Openssl,Php 7.2,我试图在RedHat操作系统上编译PHP7.2.5。我已经在自己的/home/user/OpenSSL-1.1目录中自己编译了OpenSSL 1.1.0h。以下是我如何编译OpenSSL TARGET_DIR=/home/usr/openssl-1.1 # ... ./config no-shared --prefix=${TARGET_DIR} --openssldir=${TARGET_DIR}/conf make INSTALL_PREFIX=${TARGET_DIR} make inst

我试图在RedHat操作系统上编译
PHP7.2.5
。我已经在自己的
/home/user/OpenSSL-1.1
目录中自己编译了
OpenSSL 1.1.0h
。以下是我如何编译
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
现在,我想将
PHP7.2.5
与已编译的OpenSSL版本一起编译。我是这样做的:

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"
但在某个时刻,我得到了以下错误信息:

configure: error: Cannot find OpenSSL's <evp.h>
configure:错误:找不到OpenSSL的
此文件
evp.h
存在于目录
/home/user/openssl-1.1/include/openssl


有人知道如何解决这个问题吗?

我已经找到了解决这个问题的方法:必须将两个参数
——使用openssl
——使用libdir
更改为类似以下内容:

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

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

我已经用PHP7.2和7.4进行了测试

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

程序:

  • 安装OpenSSL
  • 导出变量PKG_CONFIG_PATH以指向pkgconfig目录
  • 编译并安装PHP
  • 测试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
    
    
    export PKG_CONFIG_PATH=/opt/openssl-1.1.1i/bin/lib/pkgconfig
    
    
    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
    
    
    /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