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.


You are applying a mimetype where a handler should be (see documentation on handlers)

Try this instead:

AddType application/x-httpd-php5 .php

EDIT: As you have indicated caching modules are loaded, you could read up on caching and htcacheclean (to clear the disk cache). You can also temporarily use the CacheDisable directive. One other thing that you could also try is to rename the file that you have requested (e.g. index.php -> index.bak), request the file again in the browser (should now 404), then revert and try again.