Php – Apache 24 not serving PHP on FreeBSD 10

apache-2.4freebsdPHP

I've been at this for a few hours now. I cannot figure out WHAT is wrong with my configuration. When I navigate to any php file (wordpress installation is the intent), it opens the file for download rather then rendering/serving it.

I built (in order) Apache24, PHP55, PHP55-extensions, mod_php5.

I added the following to httpd.conf

LoadModule php5_module libexec/apache24/libphp5.so
LoadModule rewrite_module libexec/apache24/mod_rewrite.so

and I also added index.php like so:

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

<IfModule mod_php5.c>
    DirectoryIndex index.php index.html index.htm
    AddType application/x-httpd-php .php
</IfModule>

When Apache starts, it starts without any errors or warnings and this is my entire error log:

[Sat Nov 22 10:28:53.125634 2014] [core:notice] [pid 17892] AH00094: Command line: '/usr/local/sbin/httpd -D NOHTTPACCEPT'
[Sat Nov 22 10:43:03.724529 2014] [mpm_prefork:notice] [pid 17892] AH00169: caught SIGTERM, shutting down
[Sat Nov 22 10:43:03.883893 2014] [mpm_prefork:notice] [pid 17995] AH00163: Apache/2.4.10 (FreeBSD) PHP/5.5.19 configured -- resuming normal operations
[Sat Nov 22 10:43:03.883968 2014] [core:notice] [pid 17995] AH00094: Command line: '/usr/local/sbin/httpd -D NOHTTPACCEPT'
[Sat Nov 22 11:15:53.541441 2014] [mpm_prefork:notice] [pid 17995] AH00169: caught SIGTERM, shutting down
[Sat Nov 22 11:15:53.746420 2014] [mpm_prefork:notice] [pid 14477] AH00163: Apache/2.4.10 (FreeBSD) PHP/5.5.19 configured -- resuming normal operations
[Sat Nov 22 11:15:53.746504 2014] [core:notice] [pid 14477] AH00094: Command line: '/usr/local/sbin/httpd -D NOHTTPACCEPT'

I've built, configured and reinstalled this multiple times now and I still can't figure out how to make it work.

If there is something else I can post to help, please let me know.

Best Answer

Try the next config:

LoadModule php5_module        libexec/apache24/libphp5.so

<IfModule php5_module>
    <FilesMatch "\.(php|phps|php5|phtml)$">
        SetHandler php5-script
    </FilesMatch>
    DirectoryIndex index.php
</IfModule>

<IfModule mime_module>

    ...

    AddType application/x-httpd-php-source .phps
    AddType application/x-httpd-php        .php

    ...

</IfModule>

I hope this help.

Related Topic