PHP files are downloaded by browser instead of processed by local dev server (MAMP)

I’ve had a similar issue a couple times and renaming the file did not work for me. With OS X Lion I found the right configuration is this:

<IfModule php5_module>
    AddType application/x-httpd-php .php
    <FilesMatch \.php$>
        SetHandler application/x-httpd-php
    </FilesMatch>
    AddType application/x-httpd-php-source .phps
    <IfModule dir_module>
        DirectoryIndex index.php index.html
    </IfModule>
</IfModule>

The magic that made it work for me is the SetHandler application/x-httpd-php part.

Of course edit the <IfModule php5_module> to your php version.

Leave a Comment