Installed Apache 2.4 (httpd) using Home Brew, can I get it to use macOS' php7?

Just install php with brew (and leave Apple's PHP alone):

  1. brew install php (requires a lot of additional packets)
  2. Modify /usr/local/etc/httpd/httpd.conf at the end of the LoadModule section (~ line 182) and add

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

    Check that DirectoryIndex (~line 286) includes index.php

    DirectoryIndex index.php index.html
    
  3. Start php:

    brew services start php
    
  4. Restart apache