Running FreeBSD 11, I am having trouble getting Apache 2.4 to work with PHP 7.1.

  1. Built apache24 from ports
  2. Built php71 from ports
  3. Added index.php to DirectoryIndex (httpd.conf):

    <IfModule dir_module>
        DirectoryIndex index.html index.php

  4. Added the following to the end of httpd.conf:

    <FilesMatch .php$>
        SetHandler None
        ForceType text/plain
    <FilesMatch .phps$>
        SetHandler application/x-httpd-php-source

index.php output
PHP does not execute, still, and I am having trouble finding details and resources to figure this out, so I am hoping someone here can offer a bit of insight.


Apache/PHP is handling .php files as text, because you told it to do it.

While your .phps handler is ok, you are telling Apache/PHP to handle .php files as text.

.php ->  SetHandler None ; ForceType text/plain

.phps$ -> SetHandler application/x-httpd-php-source

If you really want to use .php files as PHP scripts/programs, you need to setup it up with the same configuration as you have done with .phps

  • thank you for such quick response! I should have caught that bit, but even after I changed the config, it still does not compile php code: <FilesMatch "\.php$"> SetHandler application/x-httpd-php-source </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> .. Any idea what I am missing? Might I have forgotten something when I compiled PHP71 and/or apache24? May 7 '17 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.