So I've been following along with This Tutorial, which helps configure Apache 2.4 with multiple versions of PHP. Everything was going quite smoothly, and all of my PHP versions worked, except for 7.1. When attempting to start the Apache server to receive the phpinfo of 7.1, I received the following error message:
httpd: Syntax error on line 178 of
/usr/local/etc/apache2/2.4/httpd.conf:
Cannot load /usr/local/opt/php71/libexec/apache2/libphp7.so into server:
dlopen(/usr/local/opt/php71/libexec/apache2/libphp7.so, 10): image not found
This is the code that exists on line 178:
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
I tried running
brew reinstall php71 --with-httpd24
and restarted the Apache server. Still receiving the same error message. Any idea what went wrong? I appreciate any responses! Many thanks!
I had the same problem.
For me, homebrew has a different folder structure in /usr/local/opt
where folders are more like /usr/local/opt/[email protected]
So I needed to find where libphp7.so
lived, or if it existed at all.
Running find /usr -name "libphp7.so"
Came back with:
/usr/libexec/apache2/libphp7.so
and
/usr/local/Cellar/[email protected]/7.1.15/lib/httpd/modules/libphp7.so
Both work in place of /usr/local/opt/php71/libexec/apache2/libphp7.so
for me and I'll update if required in the future.
So I updated httpd.conf
to use
LoadModule php7_module /usr/local/Cellar/[email protected]/7.1.15/lib/httpd/modules/libphp7.so
Then I restarted apache with sudo apachectl -k restart
and all is well.