6

After upgrading to MacOS Mojave, Apache can't load PHP extensions anymore. With any extension I get the error below on the Apache log; it seems that Apple implemented Library Validation through Apache on MacOS Mojave. That makes it apparently impossible to load unsigned binaries with Apache.

Is there any workaround that would not involve to disable MacOS's SIP?

Failed loading //usr/local/php/extensions/xdebug.so:  dlopen(//usr/local/php/extensions/xdebug.so, 9): no suitable image found.  Did find:
        //usr/local/php/extensions/xdebug.so: code signature in =(//usr/local/php/extensions/xdebug.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. //usr/local/php/extensions/xdebug.so: stat() failed with errno=22

10
  • 1
    See this thread for workarounds: (1) Install apache and php from homebrew (answer by suneet64), (2) Add to /etc/apache2/httpd.conf the line LoadModule php7_module libexec/apache2/libphp7.so at the end, (3) Still in /etc/apache2/httpd.conf uncomment line 545 that says Include /private/etc/apache2/other/*.conf. Let me know if one or more of them solved the problem and I will add a more detailed answer.
    – harrymc
    Commented Oct 1, 2018 at 20:22
  • same problem here with dispatcher-apache2.4-4.2.0.so
    – David Gras
    Commented Oct 2, 2018 at 8:39
  • @harrymc Thanks for the suggestion, but is there any other workaround that does not involve having to install a new instance of apache / php ? Commented Oct 2, 2018 at 13:46
  • The above workarounds are independent. Try number (2) and (3) and wait with (1) until you decide to try it.
    – harrymc
    Commented Oct 2, 2018 at 14:15
  • @harrymc Should i do 2 AND 3, or only 2 or 3 ? Commented Oct 2, 2018 at 15:42

2 Answers 2

3

The thread Installing on Mojave lists several independent workarounds:

  1. Uninstall apache and php from your computer and clean up all leftovers
  2. Install apache and php from homebrew (answer by suneet64)
  3. Add at the end of /etc/apache2/httpd.conf the line

    LoadModule php7_module libexec/apache2/libphp7.so
    
  4. Still in /etc/apache2/httpd.conf uncomment line 545 that says

    Include /private/etc/apache2/other/*.conf
    
5
  • For cleaning up see this answer. You might at the last just search the file system for *httpd* to find leftovers, but be very careful to uninstall them correctly.
    – harrymc
    Commented Oct 2, 2018 at 18:05
  • Thank you, i could remove one of them. But now i can't find where is the correct Apache's access / error log ; how can i know where are them ? The ones on '/private/var/log/apache2' are not being updated. Commented Oct 2, 2018 at 18:17
  • I don't know your setup, so all I can say is that for a clean state you should ensure first that there are no leftovers on the computer. Search for known file names to be sure that you got all of them etc. There is only so much that I can do from far away.
    – harrymc
    Commented Oct 2, 2018 at 18:20
  • I found it, i'm almost there. Now when i add the line 'LoadModule php7_module libexec/apache2/libphp7.so', i get this error : httpd: Syntax error on line 535 of /usr/local/etc/httpd/httpd.conf: Cannot load libexec/apache2/libphp7.so into server: dlopen(/usr/local/opt/httpd/libexec/apache2/libphp7.so, 10): image not found Commented Oct 2, 2018 at 18:25
  • "image not found" : you need to find where is libphp7.so. But did you test without it?
    – harrymc
    Commented Oct 2, 2018 at 19:12
1

What helps me:

brew update

brew upgrade

and as result i get info

==> [email protected]
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so

    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/7.3/

I was confused bcs it was a few httpd.conf but finnaly in my case it was : /usr/local/etc/httpd/httpd.conf

So i done edit as homebrew info says: 1 Add this lines:

LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so
    
        <FilesMatch \.php$>
            SetHandler application/x-httpd-php
        </FilesMatch>

And found and changed section DirectoryIndex as follows:

<IfModule dir_module>
    #DirectoryIndex index.html
    DirectoryIndex index.php index.html
</IfModule>

And now php is working. Hope this helps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .