3
votes

When I recently installed PHP56 via Homebrew, Apache would no longer start, with this error in the logs:

Cannot load /usr/local/opt/php56/libexec/apache2/libphp5.so into server: dlopen(/usr/local/opt/php56/libexec/apache2/libphp5.so, 10): image not found

Note: I'm running Apache 2.4 on Mac El-Capitan.

How can I resolve this error and get Apache running again?

1

1 Answers

6
votes

I've seen this before. If you brew options php56, it says:

With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-apache option. See brew options php56 for more details.

Thus, try uninstalling (brew uninstall php56) then reinstalling php56 with the flag --with-apache for Apache v2.4.x (--with-apache22 for Apache 2.2). Generally, you can check your Apache version by typing in command line: httpd -v.

My version is 2.4.18, so I would brew install php56 --with-apache, which creates the proper file path /usr/local/opt/php56/libexec/apache2/libphp5.so.

Now, it is properly compiled with Apache Handler module.

IMPORTANT: installing php56 with this option appears to also install httpd24. From a brew program stance, this makes sense. However, this may break your server set up. If you don't want to use brew's Apache install, do a brew unlink httpd24 after this.

To see additional brew build options, try brew options php56.