Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP7.2 module fails to load in macOS mojave (14.2) #32436

Closed
paschaldev opened this issue Sep 25, 2018 · 11 comments

Comments

@paschaldev
Copy link

commented Sep 25, 2018

just updated to macOS mojave and unfortunately I can't get php7_module to load with the default apache on macOS.

Firstly, I installed with brew install php, after successfully installing. I added this line to my apache as instructed in terminal

httpd.conf

...
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
...

Now when I run sudo apachectl restart, I tried to reload my webpage and I get no response as if the server did not start at all. So I ran sudo apachectl and I see this in my terminal.

httpd: Syntax error on line 178 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/opt/php/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/opt/php/lib/httpd/modules/libphp7.so, 10): no suitable image found.  Did find:\n\t/usr/local/opt/php/lib/httpd/modules/libphp7.so: code signature in (/usr/local/opt/php/lib/httpd/modules/libphp7.so) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.\n\t/usr/local/opt/php/lib/httpd/modules/libphp7.so: stat() failed with errno=22

Looked online and found about a problem related to SIP on Mac so I turned SIP off from recovery with csrutil disable. Restarted my system and when I run sudo apachetl, I get this new error.

httpd: Syntax error on line 178 of /private/etc/apache2/httpd.conf: Cannot load local/opt/php/lib/httpd/modules/libphp7.so into server: dlopen(/usr/local/opt/php/lib/httpd/modules/libphp7.so, 10): Symbol not found: _libiconv\n  Referenced from: /usr/local/opt/php/lib/httpd/modules/libphp7.so\n  Expected in: /usr/lib/libiconv.2.dylib\n in /usr/local/opt/php/lib/httpd/modules/libphp7.so
@SMillerDev

This comment has been minimized.

Copy link
Member

commented Sep 26, 2018

It's not made to work with the default apache and disabling SIP is a terrible advice in any case.

@paschaldev

This comment has been minimized.

Copy link
Author

commented Sep 26, 2018

Alright thank you @SMillerDev. Found a way out

@paschaldev paschaldev closed this Sep 26, 2018

@samir76

This comment has been minimized.

Copy link

commented Oct 1, 2018

@paschaldev Can you share with us the way out that you found to solve the issue, please.

@paschaldev

This comment has been minimized.

Copy link
Author

commented Oct 2, 2018

@samir I restarted my system and somehow it started working

@samir76

This comment has been minimized.

Copy link

commented Oct 3, 2018

@paschaldev restarting didn't work for me, but I found an answer that worked from this link -
https://stackoverflow.com/questions/44981521/homebrew-php-7-1-macos-sierra-apache-syntax-error

@pratiksahu

This comment has been minimized.

Copy link

commented Oct 3, 2018

  • Install homebrew apache (brew install httpd)
  • disable the default apache (sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist)
  • update the httpd configuration for php7 module (/usr/local/etc/httpd is the path for new apache)
  • LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
  • brew services restart httpd
  • Default configuration of http of homebrew uses port 8080 - you can update the configuration in httpd.conf to 80
@SMillerDev

This comment has been minimized.

Copy link
Member

commented Oct 3, 2018

Those are both solutions to a different problem though. The initial problem was an iconv library that could no longer be found. This is a solution for a completely missing PHP binary.

@francosalcedo

This comment has been minimized.

Copy link

commented Oct 5, 2018

I have the same problem, some viable solution? :(

@SMillerDev

This comment has been minimized.

Copy link
Member

commented Oct 5, 2018

If you have the issue in the main post, could you print the output of brew linkage php?

@yagrasdemonde

This comment has been minimized.

Copy link

commented Oct 5, 2018

The solution is like @pratiksahu said : you have to install new apache server (with brew install httpd).
and deactivate built in apache Mac Os. It seems the built in apache Mac Os doesn't work with php 7.2.

For me it works like a charm.

@SMillerDev

This comment has been minimized.

Copy link
Member

commented Oct 5, 2018

That's a completely different issue then was first raised, @francosalcedo if you have the same issue as @paschaldev can you make a new issue? This one is getting derailed

@Homebrew Homebrew locked and limited conversation to collaborators Oct 5, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants
You can’t perform that action at this time.