I'm running macOS 10.15 (Catalina) and have installed the latest Apache (2.4.43) using brew
, basically following these steps.
Seems to be working fine, but now I want to enable PHP 7 in Apache as well.
I have the default PHP that comes with macOS Catalina (php -v
says 7.3.11) however Apache's module dir (at least the latest Apache I installed with Home Brew) does not seem to contain any php modules.
I'm quite unsure what LoadModule
line I have to add in httpd.conf
in order to get PHP 7 working in my Apache server. And how or where I should get a PHP 7 .so module file if necessary.
When searching around I find all sorts of different approaches, including installing custom versions of PHP but I'm somewhat reluctant of the risk of messing up my current installation.
Is there an easy, and more importantly: reliable way of enabling PHP 7 in httpd 2.4?
Best Answer
Just install php with brew (and leave Apple's PHP alone):
brew install php
(requires a lot of additional packets)Modify /usr/local/etc/httpd/httpd.conf at the end of the LoadModule section (~ line 182) and add
Check that DirectoryIndex (~line 286) includes index.php
Start php: