Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu 22.04 LTS - openssl error #1263

Closed
simonovich opened this issue May 25, 2022 · 7 comments
Closed

Ubuntu 22.04 LTS - openssl error #1263

simonovich opened this issue May 25, 2022 · 7 comments
Assignees
Labels
Debian | Ubuntu OpenSSL Issues related to compiling PHP with OpenSSL PHP 7.4 Support

Comments

@simonovich
Copy link

Output

$ phpbrew --debug install 7.4 +default
===> phpbrew will now build 7.4.29
---> Parsing variants from command arguments '+default'
===> Loading and resolving variants...
Checking distribution checksum...
Checksum matched: 7dde58a02b225c25130c6e2ae2cbba7254bb0340f7fe17291478176d866f9482
===> Distribution file was successfully extracted, skipping...
Source Directory: /home/simonovich/.phpbrew/build/php-7.4.29
Found existing Makefile, running make clean to ensure everything will be rebuilt.
You can append --no-clean option after the install command if you don't want to rebuild.
===> Running make clean: /usr/bin/make -C '/home/simonovich/.phpbrew/build/php-7.4.29' --quiet 'clean'
Running Command:/usr/bin/make -C '/home/simonovich/.phpbrew/build/php-7.4.29' --quiet 'clean'
Writing variant info to /home/simonovich/.phpbrew/php/php-7.4.29/phpbrew.variants
===> Checking patches...
Checking patch for replace apache php module name with custom version name
Checking patch for replace freetype-config with pkg-config on php older than 7.4
Enabled variants: [xml, opcache, bcmath, bz2, calendar, cli, ctype, dom, fileinfo, filter, ipc, json, mbregex, mbstring, mhash, pcntl, pcre, pdo, pear, phar, posix, readline, sockets, tokenizer, curl, openssl, zip]
Disabled variants: []
Found existing build.log, renaming it to /home/simonovich/.phpbrew/build/php-7.4.29/build.log.1653480765
===> Configuring 7.4.29...


Use tail command to see what's going on:
   $ tail -F '/home/simonovich/.phpbrew/build/php-7.4.29/build.log'


./configure '--cache-file=/home/simonovich/.phpbrew/cache/config.cache' '--prefix=/home/simonovich/.phpbrew/php/php-7.4.29' '--with-config-file-path=/home/simonovich/.phpbrew/php/php-7.4.29/etc' '--with-config-file-scan-dir=/home/simonovich/.phpbrew/php/php-7.4.29/var/db' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--with-zlib=/usr' '--with-libdir=lib/x86_64-linux-gnu' '--enable-dom' '--with-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-opcache' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash' '--enable-pcntl' '--enable-pdo' '--with-pear=/home/simonovich/.phpbrew/php/php-7.4.29/lib/php/pear' '--enable-posix' '--with-readline=/usr' '--enable-sockets' '--with-curl' '--with-openssl' '--with-zip' 'PKG_CONFIG_PATH=/usr/lib/pkgconfig' >> '/home/simonovich/.phpbrew/build/php-7.4.29/build.log' 2>&1
===> Checking patches...
Checking patch for php5.3.x on 64bit machine when intl is enabled.
Checking patch for openssl dso linking patch
Checking patch for php5.6 with openssl 1.1.x patch.
===> Building...
make >> '/home/simonovich/.phpbrew/build/php-7.4.29/build.log' 2>&1
Error: Make failed:
The last 5 lines in the log file:
In file included from /home/simonovich/.phpbrew/build/php-7.4.29/ext/openssl/openssl.c:46:

/usr/include/openssl/rsa.h:289:29: note: expected ‘RSA *’ {aka ‘struct rsa_st *’} but argument is of type ‘const struct rsa_st *’

  289 |                        RSA *rsa, int padding);

      |                        ~~~~~^~~

make: *** [Makefile:638: ext/openssl/openssl.lo] Ошибка 1

Please checkout the build log file for more details:
	 tail /home/simonovich/.phpbrew/build/php-7.4.29/build.log

Expected Result

Install complete

Command

phpbrew --debug install 7.4 +default

Build Log

See up

Platform

OS:

Ubuntu 22.04 LTS

Running PHP:
PHP 8.1.2 (cli) (built: Apr 7 2022 17:46:26) (NTS)

Installing PHP:
PHP 7.4.29

@peter279k
Copy link
Member

peter279k commented May 29, 2022

The problem is about the OpenSSL and libssl versions are changed since Ubuntu 22.04 is released.

By default, it inclues the OpenSSL 3 and libssl3 in Ubuntu 22.04. But compiling the PHP-7.4 version needs to use the libssl1.1 when compiling the openssl extension.

To resolve the above issue, it should compile the opnessl1.1 from source in Ubuntu 22.04 and setting the PKG_CONFIG_PATH environment variable to specify the openssl1.1 path.

Here are steps to resolve the above issue:

Compile the OpenSSL 1.1 from source

cd $HOME
wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
tar xzf $HOME/openssl-1.1.1i.tar.gz
cd openssl-1.1.1i
./Configure --prefix=$HOME/openssl-1.1.1i/bin -fPIC -shared linux-x86_64
make -j 8 
make install

Compile the PHP 7.4.29 with PHPBrew

export PKG_CONFIG_PATH=$HOME/openssl-1.1.1i/bin/lib/pkgconfig && phpbrew --debug install 7.4 +default

Verification

lee@lee-VirtualBox:~$ phpbrew switch php-7.4.29
lee@lee-VirtualBox:~$ php -v
PHP 7.4.29 (cli) (built: May 29 2022 12:34:15) ( NTS )
Copyright (c) The PHP Group
lee@lee-VirtualBox:~$ php -i | grep -i openssl
Configure Command =>  './configure'  '--cache-file=/home/lee/.phpbrew/cache/config.cache' '--prefix=/home/lee/.phpbrew/php/php-7.4.29' '--with-config-file-path=/home/lee/.phpbrew/php/php-7.4.29/etc' '--with-config-file-scan-dir=/home/lee/.phpbrew/php/php-7.4.29/var/db' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--with-zlib=/usr' '--with-libdir=lib/x86_64-linux-gnu' '--enable-dom' '--with-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-opcache' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash' '--enable-pcntl' '--enable-pdo' '--with-pear=/home/lee/.phpbrew/php/php-7.4.29/lib/php/pear' '--enable-posix' '--with-readline=/usr' '--enable-sockets' '--with-curl' '--with-openssl' '--with-zip' 'PKG_CONFIG_PATH=/usr/lib/pkgconfig:/home/lee/openss
-1.1.1i/bin/lib/pkgconfig:/home//lee/openssl-1.1.1i/bin/lib/pkgconfig'
libSSH Version => libssh/0.9.6/openssl/zlib
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 => /home/lee/openssl-1.1.1i/bin/ssl/openssl.cnf
openssl.cafile => no value => no value
openssl.capath => no value => no value
Native OpenSSL support => enabled
PKG_CONFIG_PATH => /home//lee/openssl-1.1.1i/bin/lib/pkgconfig
$_SERVER['PKG_CONFIG_PATH'] => /home//lee/openssl-1.1.1i/bin/lib/pkgconfig

References

@peter279k
Copy link
Member

peter279k commented May 29, 2022

Just notify that I also update the Troubleshooting page to add this issue :).

@bcag2
Copy link

bcag2 commented Jun 30, 2022

@peter279k wrote

Here are steps to resolve the above issue:

Compile the OpenSSL 1.1 from source

cd $HOME
wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
tar xzf $HOME/openssl-1.1.1i.tar.gz
cd openssl-1.1.1i
./Configure --prefix=$HOME/openssl-1.1.1i/bin -fPIC -shared linux-x86_64
make -j 8 
make install

Compile the PHP 7.4.29 with PHPBrew

export PKG_CONFIG_PATH=$HOME/openssl-1.1.1i/bin/lib/pkgconfig && phpbrew --debug install 7.4 +default

At this point it returns error :

Error: Configure failed:
The last 5 lines in the log file:
installed software in a non-standard prefix.
Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

then if I open build.log (~/.phpbrew/build/php-7.4.30/build.log) :

checking for oniguruma... no
configure: error: Package requirements (oniguruma) were not met:

No package 'oniguruma' 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 ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

@peter279k
Copy link
Member

@bcag2, this is not related to the OpenSSL error. It seems that you miss the oniguruma packages.

Please install the oniguruma package with the sudo apt-get install libonig-dev command.

The related troubleshooting issue is available here.

@elvisoliveira
Copy link

This is how I got it working, based on @peter279k solution:

cd $HOME/openssl-1.1.1i/bin
export LDFLAGS="-L$(pwd)/lib"
export CPPFLAGS="-I$(pwd)/include"
phpbrew --debug install 7.4 +default

I'm on Arch Linux 5.15.79-1-lts

@ttodua
Copy link
Contributor

ttodua commented Dec 7, 2022

@peter279k
Copy link
Member

peter279k commented Dec 8, 2022

The above solution is only worked in the macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Debian | Ubuntu OpenSSL Issues related to compiling PHP with OpenSSL PHP 7.4 Support
Projects
None yet
Development

No branches or pull requests

5 participants