Configuring Apache for PHP

apache-http-serverhomebrewmacPHP

On my MacBook Pro, I used HomeBrew to install a new version of Apache and PHP. The problem I am dealing with right now is that I've got a problem in my apache configuration file such that php files are not getting run by the PHP module, are are just being displayed as raw text

Here is my test.php file:

<!DOCTYPE HTML5>
<HTML>
<BODY>
<?php
echo "PHP Active!";
?>
</BODY>
</HTML>

When I open it in Safari it shows the whole (unprocessed) contents of the file, <!Doctype> tag and all.

In my HTTPD.conf file, I have

LoadModule php_module  /usr/local/opt/php/lib/httpd/modules/libphp.so

And

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

Again, what I'm seeing in Safari is exactly the same as the text in the file

Best Answer

I got it to work by following the instructions on https://www.git-tower.com/blog/apache-on-macos/#installation . The HomeBrew directory mentioned on this page wasn't there, so I put the included file in the same directory as the httpd.conf file.

Related Question