No code signing authority for module php on Mac Monterey
Mac Monterey and future Mac OS requires all application to be verified in order to run them on the OS. The php installed from brew is not a verified application and it has to be verified in order for it to run on Mac, without it being verified and loading it in apache, the apache server will fail to start with this error:
No code signing authority for module at /usr/local/opt/php/lib/httpd/modules/libphp.so specified in LoadModule directive.
To resolve this issue, you can use the codesign to sign the php module and then load it in the httpd.conf with authority.
1. If codesign is not yet available, install it with this command
xcode-select --install
2. Open Keychain Access by press CMD+Space, type Keychain Access, open Keychain Access, then create a Certificate Authority and a code signing certificate, and they will be used with codesign to sign the php module and make it a verified application. Here are some excellent articles with instructions for creating Certificate Authority and code signing certificate.
– https://blog.phusion.nl/2020/12/22/future_of_macos_apache_modules/
– https://www.simplified.guide/macos/keychain-ca-code-signing-create
– https://www.simplified.guide/macos/keychain-cert-code-signing-create
3. After the Certificate Authority and code signing certificate are created, use codesign to sign the php module. Use the common name you used for creating the code signing certificate, if the common name is “John Doe”, the codesign command would be
codesign --sign "John Doe" --force --keychain ~/Library/Keychains/login.keychain-db /usr/local/opt/php/lib/httpd/modules/libphp.so
4. Check the Authority of the signed php module.
codesign -dv --verbose=4 "/usr/local/opt/php/lib/httpd/modules/libphp.so"
5. After the php module is signed, open the apache config file /etc/apache2 and update the line where it loads the php module to the following. Replace John Doe with the Authority shown from step 4, it should be the same as the common name you used for creating the code signing certificate.
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so "John Doe"
6. Restart apache server
apachectl restart
7. Check apache config and errors.
apachectl configtest cat /var/log/apache2/error_log
Search within Codexpedia
Search the entire web