Reputation: 323
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!
Upvotes: 10
Views: 22945
Reputation: 704
I had the same problem.
This was the solution for me:
My chip is Apple M1, running macOS Big Sur version 11.4.
I had to change this line (the module path) in httpd.conf:
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
to this:
LoadModule php7_module /opt/homebrew/opt/[email protected]/lib/httpd/modules/libphp7.so
Upvotes: 0
Reputation: 11
I had the same issue but with php 7.2.
Running brew linkage php
showed that there were some broken dependencies.
So running brew update && brew upgrade
resolved it for me.
Upvotes: 1
Reputation: 53
I had a PHP update, the file path has been changed. I changed the module path in httpd.conf
.
Before:
LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so
After:
LoadModule php7_module /usr/local/Cellar/php/7.4.12/lib/httpd/modules/libphp7.so
Upvotes: 1
Reputation: 26
in usr/local/opt there was an folder(alias) php only
`Just duplicate the php Alias-Folder and rename it to [email protected]`
after that sudo apache graceful I was done
Upvotes: 0
Reputation: 41
Homebrew instructed to add this to my httpd.conf file:
LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so
I tried stopping and restarting only to get the same error. After updating several times with different options, this one finally worked for me.
LoadModule php7_module /usr/libexec/apache2/libphp7.so
Upvotes: 3
Reputation: 499
I'm getting this error with the brew install php. then apachectl -t to test syntax
httpd: Syntax error on line 180 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/Cellar/php/7.3.2/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/Cellar/php/7.3.2/lib/httpd/modules/libphp7.so, 10): Symbol not found: _sqlite3_enable_load_extension\n Referenced from: /usr/local/Cellar/php/7.3.2/lib/httpd/modules/libphp7.so\n Expected in: /usr/lib/libsqlite3.dylib\n in /usr/local/Cellar/php/7.3.2/lib/httpd/modules/libphp7.so
For some reason??? I found the libphp7.so here
LoadModule php7_module /usr/libexec/apache2/libphp7.so
Plugged it in and it works. However - I'm no clearer as to why the first one is failing.
Upvotes: 3
Reputation: 2971
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.
Upvotes: 29