Articles

How to install PHP on Mac OS Monterey

Update to the latest Homebrew, Xcode etc.

brew install php

brew link php

check php version with #php -v

create a self signed certificate in Keychain Access

Codesign the php apache module

codesign --sign "MacOS SSL" --force --keychain ~/Library/Keychains/login.keychain-db /usr/local/opt/php@8.1/lib/httpd/modules/libphp.so

Go edit apache config usually /etc/apache2/httpd.conf

Add your PHP module location and add the certifcate 

LoadModule php_module /usr/local/opt/php@8.1/lib/httpd/modules/libphp.so "Blake SSL"

Also add a file match for PHP file types:

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

Restart apache: #sudo apachectl restart

Check apache is now loading PHP with: #apachectl -M

Check PHP in browser with phpinfo()

Resources I found useful:

https://www.codexpedia.com/apache-server/no-code-signing-authority-for-module-php-on-mac-monterey/

https://wpbeaches.com/updating-to-php-versions-7-4-and-8-on-macos-12-monterey/

https://blog.phusion.nl/2020/12/22/future_of_macos_apache_modules/

https://www.simplified.guide/macos/apache-php-homebrew-codesign 

 

Comments

0 comments

Post a comment

Please insert the result of the arithmetical operation from the following image:

Please insert the result of the arithmetical operation from this image.
=

HomeInsightsHow to install PHP on Mac OS Monterey

say hello

Shift

47 Southgate Street
Winchester
Hampshire, SO23 9EH

SHIFT DIGITAL LIMITED Registered in UK & Wales #09680976 | VAT #412631729
47 Southgate Street, Winchester, Hampshire, SO23 9EH | Main email: hello@shift.digital | Main Office: +44 (0) 1962 4350 40
Terms and conditions | Privacy