Skip to content

PHP Installation fails on Ubuntu 22.04 WSL2 #1280

Closed
@7ahery

Description

@7ahery

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.

  1. Remove current (version 3) OpenSSL: sudo apt remove openssl
  2. Download OpenSSL 1.1.1 source, extract the .tar.gz file and build/install OpenSSL:
    1. cd to OpenSSL source folder.
    2. make config file executable: chmod +x config
    3. run config: ./config
    4. build the source: make
    5. run tests to make sure the built source is OK: make test
    6. install the built OpenSSL: sudo make install
  3. 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions