0

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

4
  • As a first step, check the logs, then load mod_info.so and go to ..../server-info and see what is getting loaded.
    – Bib
    Aug 1, 2021 at 19:51
  • The file should be called test.html, not test.php.
    – Bib
    Aug 1, 2021 at 21:01
  • @Bib The Php module is being loaded. Aug 4, 2021 at 12:53
  • @Bib when I rename the file to use the .html extension, I get a blank page (which makes sense if you process the page as straight HTML and not invoke the PHP) I also tried creating a test.txt copy. Loading that in the browser looks just like what I described above. It seems to me that the issue is that the file is not getting run through the PHP engine/.so Aug 4, 2021 at 12:57

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .