PHP is removed when I upgraded my Macbook Pro M1 from Big Sur to Monterey. Apache web server is still running though.
This solution doesn’t work! I blog it as reference for others that it doesn’t work so they can try another solution.
I’m still figuring it out. 🙂
My phpMyAdmin is showing its PHP Code

Install Rosetta2
1 |
/usr/sbin/softwareupdate --install-rosetta --agree-to-license |
Install PHP
1 |
arch -x86_64 brew install php@8.0 |
Link the PHP
1 |
brew link php |
Check if PHP is installed
1 |
php -v |
if correctly installed, you will see
1 2 3 4 |
PHP 8.0.13 (cli) (built: Nov 19 2021 09:05:44) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.13, Copyright (c) Zend Technologies with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies |
Location of php.ini
1 |
/usr/local/etc/php/8.0/ |
Edit Apache httpd.conf
1 |
nano /etc/apache2/httpd.conf |
Change These Settings inside httpd.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# Apache stops working when load php module. If comment the php module it # works again. # I tried load 2 php module which the path n file exists but still fail LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so # LoadModule php_module /usr/local/opt/php@8.0/lib/httpd/modules/libphp.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> <IfModule dir_module> DirectoryIndex index.php index.html </IfModule> |
References:
https://laracasts.com/discuss/channels/servers/php-shown-as-plaintext-mac-monterey
https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions
https://stackoverflow.com/questions/64963370/error-cannot-install-in-homebrew-on-arm-processor-in-intel-default-prefix-usr