0

I am trying to load either PHP 5.6 or PHP 7.0 module in the Apache httpd.conf config file on macOS 10.15 Catalina. But what I receive when starting the Apache server using sudo apachectl start in Terminal is the following error:

httpd: Syntax error on line 187 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so into server: dlopen(/usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so, 10): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib\n Referenced from: /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so\n  Reason: image not found

Since PHP versions 5.6, 7.0 and 7.1 have been deprecated and removed from Homebrew, following this guide, I had to use an older deprecated tap and installed both PHP 5.6 and 7.0 by running:

brew tap exolnet/homebrew-deprecated
brew install php@5.6
brew install php@7.0

For the sake of complete information, I have tried both the Apache which comes with macOS and the latest Apache 2.4.43 installed via Homebrew, but this should not make a difference.

So the question is, how can I solve these errors and make PHP 5.6 and 7.0 running on macOS using Homebrew?

Adam
  • 1,926
  • 23
  • 21

1 Answers1

0

The solution is to install an older version of the openssl library. To be more specific, PHP 5.6 and php 7.0 require openssl 1.0.2, which you can install via Homebrew by running the following in Terminal:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/8b9d6d688f483a0f33fcfc93d433de501b9c3513/Formula/openssl.rb
brew switch openssl 1.0.2t

However, after running the above, when using PHP 5.6, php 7.0 or php 7.1, another "Library not loaded" error might occur., in particular, this one:

httpd: Syntax error on line 183 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so into server: dlopen(/usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so, 10): Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib\n  Referenced from: /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so\n  Reason: image not found

Here, another older library is required, icu4C in this case. The solution is to run the following:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/a806a621ed3722fb580a58000fb274a2f2d86a6d/Formula/icu4c.rb
brew switch icu4c 64.2

Note for switching to PHP 7.2, PHP 7.3 or PHP 7.4

Since PHP 7.2, PHP 7.3 and PHP 7.4 do not work with the above mentioned older, 64.3, version of the icu4c library, whenever you need to switch to these PHP versions, e.g., by using this easy brew PHP switcher script, you also hav to switch the version of the icu4c library by running this command:

brew switch icu4c 67.1

Resources

Adam
  • 1,926
  • 23
  • 21