can't seem to get php working in MAMP

I had the similar issue.

Make a new file in TextWrangler or Komodo, or whatever, and add the folllowing code:

AddType application/x-httpd-php .html .htm
AddHandler application/x-httpd-php .html .htm

You're going to save the file as .htaccess (with the dot in the front; this is the file name). Save it in /Applications/MAMP/htdocs. This is the same place you'll save your php and html files. This .htaccess will be an invisible file; you will not see it in Finder, tho you can if you cd to it in Terminal, or searching w/in Finder and choosing the File Visibility type under Kind.

Now try going to localhost:8888/ and you should see all of the available files there. And with this newly created .htaccess file, you can now embed php inside an html file too.


In MAMP, edit the file:

/Applications/MAMP/conf/apache/httpd.conf

and then search for '#AddHandler type-map' (exclude quotes). Below that, add,

AddHandler application/x-httpd-php .php .html

Save the file and stop and re-start MAMP. Php parsing will occur in files ending with the extensions: .php and .html.


You must save a file with PHP inside it with a .php extension. So you would need to name it index.php instead of index.html. Simple fix.

Tags:

Html

Php

Mamp