我正在尝试在RedHat操作系统上编译PHP 7.2.5
。我已经在我自己的OpenSSL 1.1.0h
目录中自己编译了/home/user/openssl-1.1
。这些是我编译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
。
有谁知道如何解决这个问题?
答案 0 :(得分:0)
我找到了此问题的解决方案:必须将两个参数--with-openssl
和--with-libdir
更改为以下内容:
./buildconf --force
./configure --prefix="$PHP_PREFIX" \
# ...
--with-openssl=/home/user/openssl-1.1 \
--with-libdir=lib64
据我所知,这里不需要其他环境变量。
答案 1 :(得分:0)
我已经使用PHP 7.2和7.4进行了测试
如果您以非标准前缀安装软件,请考虑调整PKG_CONFIG_PATH环境变量,将其指向OpenSSL的pkgconfig目录。
程序:
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