【问题标题】:Compiling PHP 7.2 with OpenSSL使用 OpenSSL 编译 PHP 7.2
【发布时间】:2023-03-31 21:07:01
【问题描述】:

我正在尝试在 RedHat 操作系统上编译 PHP 7.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

现在,我想将 PHP 7.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>

此文件evp.h 存在于目录/home/user/openssl-1.1/include/openssl 中。

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

【问题讨论】:

    标签: php compilation openssl php-7.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
    
    
    

    【讨论】:

      【解决方案2】:

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

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

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

      【讨论】:

        猜你喜欢
        • 2015-01-18
        • 1970-01-01
        • 1970-01-01
        • 2014-04-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-21
        相关资源
        最近更新 更多