I'm setting up a new macbook (Monterey 12.2.1 chip Apple M1 Pro), and installed PHP 7.4 with homebrew. I configured PHP to run as a module for the Apache2 server that comes with MacOS (Apache/2.4.51). I immediately ran into trouble because gatekeeper wouldn't allow me to run php as an apache module from homebrew until I codesigned it. I did codesign it:
codesign --sign "Mike Andersen" --force --keychain ~/Library/Keychains/login.keychain-db /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so
And afterwards PHP worked perfectly. Then I installed xdebug with PECL: arch -x86_64 sudo pecl install xdebug
When I checked it from the command line, everything looked right:
php -v
PHP 7.4.28 (cli) (built: Feb 28 2022 07:33:39) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
with Xdebug v3.1.3, Copyright (c) 2002-2022, by Derick Rethans
php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/7.4
Loaded Configuration File: /opt/homebrew/etc/php/7.4/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/7.4/conf.d
Additional .ini files parsed: /opt/homebrew/etc/php/7.4/conf.d/20-ext-opcache.ini,
/opt/homebrew/etc/php/7.4/conf.d/99-xdebug.ini
But loading from a browser failed - the browser listed the 99-xdebug.ini file:
Additional .ini files parsed /opt/homebrew/etc/php/7.4/conf.d/20-ext-opcache.ini, /opt/homebrew/etc/php/7.4/conf.d/99-xdebug.ini
But nothing else about xdebug. I checked the apache error log and saw:
Failed loading /opt/homebrew/lib/php/pecl/20190902/xdebug.so:
dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so, 0x0009):
tried: '/opt/homebrew/lib/php/pecl/20190902/xdebug.so'
(code signature in <8E9B311F-7332-3812-89A8-91BA8FB71682> '/opt/homebrew/lib/php/pecl/20190902/xdebug.so'
not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)),
'/usr/lib/xdebug.so' (no such file)
I tried signing the xdebug.so file as well:
codesign --sign "Mike Andersen" --force --keychain ~/Library/Keychains/login.keychain-db /opt/homebrew/lib/php/pecl/20190902/xdebug.so
/opt/homebrew/lib/php/pecl/20190902/xdebug.so: replacing existing signature
And restarted apache, but still got the same error in the apache log. I've also tried re-signing PHP, no help. I've also tried disabling gatekeeper:
sudo spctl --master-disable
That made no difference either.
I've been googling this all morning, and can't find anything about how to address this problem. Somebody must have seen this by now, so I'm hoping one of you is that somebody and can help a brother out. Thanks in advance for any help you can offer.