Search code examples
phpbuildopensslcentos

Configure php-8.1 with openssl


I want to build php8.1 with openssl3 support. First I compiled and installed openssl3

./config -fPIC shared --prefix=/opt/openssl

make test
make install
ln -s /opt/openssl/lib64/libssl.so.3 /usr/lib64/libssl.so.3
ln -s /opt/openssl/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3
sudo mv /bin/openssl /bin/openssl.backup
ln -s /opt/openssl/bin/openssl /usr/bin/
openssl version
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)

Next I try to configure php-8.1

./configure --with-config-file-path=/etc/php \
--sysconfdir=/etc/php.d \
--enable-mysqlnd \
--with-pdo-mysql \
--with-pdo-mysql=mysqlnd \
--with-pdo-pgsql=/usr/bin/pg_config \
--enable-bcmath \
--enable-fpm \
--with-fpm-user=root \
--with-fpm-group=root \
--enable-mbstring \
--enable-phpdbg \
--enable-shmop \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-zlib \
--with-curl \
--with-pear \
--with-openssl=/opt/openssl \
--with-openssl-dir=/opt/openssl \
--enable-pcntl \
--enable-gd \
--with-jpeg \
--with-mysqli \
--with-readline \
--with-freetype \
--with-ldap

I get an error:


checking for openssl >= 1.0.2... no configure: error: Package requirements (openssl >= 1.0.2) were not met:

No package 'openssl' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.

Alternatively, you may set the environment variables OPENSSL_CFLAGS and OPENSSL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.


What am I doing wrong?


Solution

  • Good config

    ./configure  OPENSSL_CFLAGS=-I/opt/openssl/include/ OPENSSL_LIBS="-L/opt/openssl/lib64/ -lssl -lcrypto" \
    PKG_CONFIG_PATH=/usr/local/lib/pkgconfig \
    --with-config-file-path=/etc/php \
    --sysconfdir=/etc/php.d \
    --enable-mysqlnd \
    --with-pdo-mysql \
    --with-pdo-mysql=mysqlnd \
    --with-pdo-pgsql=/usr/bin/pg_config \
    --enable-bcmath \
    --enable-fpm \
    --with-fpm-user=root \
    --with-fpm-group=root \
    --enable-mbstring \
    --enable-phpdbg \
    --enable-shmop \
    --enable-sockets \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --with-zlib \
    --with-curl=/opt/curl \
    --with-pear \
    --with-openssl=/opt/openssl/bin \
    --enable-pcntl \
    --enable-gd \
    --with-jpeg \
    --with-mysqli \
    --with-readline \
    --with-freetype \