Description
Error 🔴
Running phpbrew on Ubuntu 22.04 WSL2, when I try to install any PHP version lower than 8.0
I get various errors related to OpenSSL. My take is that this is most likely related to OpenSSL 3 being the default in Ubuntu 22.04 but lower PHP versions need OpenSSL 1.1.1 to build.
Here are the errors:
Error: Configure failed:
The last 5 lines in the log file:
checking for Kerberos support... no
checking whether to use system default cipher list instead of hardcoded value... no
checking for RAND_egd... no
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's libraries
Error: Make failed:
/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:631: ext/openssl/openssl.lo] Error 1
Solution (Partial - Please read this comment)
Use At Your Own Risk
This was the only way I was able to fix these errors.
- Remove current (version 3) OpenSSL:
sudo apt remove openssl
- Download OpenSSL 1.1.1 source, extract the .tar.gz file and build/install OpenSSL:
cd
to OpenSSL source folder.- make
config
file executable:chmod +x config
- run config:
./config
- build the source:
make
- run tests to make sure the built source is OK:
make test
- install the built OpenSSL:
sudo make install
- Now install your PHP version with the following command:
phpbrew install 7.0 +default +openssl=shared -- --with-openssl-dir=/usr/include/openssl
which essentially tells the installed PHP version to use the OpenSSL path you provide.
! Important Note ! You can not have two versions of OpenSSL activated simultaneously. With this approach you are eliminating OpenSSL 3 lib from Ubuntu 22.04 so please make sure you know what you are doing.
To uninstall OpenSSL 1.1.1, cd
to OpenSSL source folder and run sudo make uninstall
.
To install back OpenSSL 3, first remove OpenSSL 1.1.1 and then run: sudo apt install openssl
.
Note: When installing PHP 5.6 you may face a curl error easy.h should be in <curl-dir>/include/curl/
. In that case please check out this answer.