I've spent hours trying to newly setup and install an Apache server running PHP 8.1.
The problem is, that php is not executed. The code of the php file is shown in the browser.
I've tried so far:
Setting up the Apache shipped with ventura: discussions.apple.com
I ended up trying the installation of the Apache with brew: getgrav.org/blog
Unfortunately it resulted in the same problem.
macOS: 13.3.1 Homebrew: 4.0.14
php -v: PHP 8.1.18
httpd.conf changes:
LoadModule php_module /usr/local/opt/php@8.1/lib/httpd/modules/libphp.so
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
In some cases the browser is redirected from http://localhost/info.php to https://localhost/info.php, which results in the message "Unable to connect".
I also signed the libphp.so since apachectl configtest complained about it.