MacOS – wrong with the PHP on the apache2 web server (OS X 10.6)

apachemacosPHPsnow leopard

I have a web server on my mac mini that runs the default (installed with snow leopard) apache2 web server. It works fine for any programming language that outputs stdout for cgi scripts, but every attempt I have made to enable PHP has failed. Please help! I can upload any files that you need to see like php.ini or httpd.conf

I have tried scanning through the php.ini file values, php5 module load is uncommented in the httpd.conf.
These are the only steps that I have seen to enable php on a mac.

php5, from what I hear, is installed by default on Mac OS X snow leopard.

Best Answer

You need to include the following directive in your httpd.conf file:

AddType application/x-httpd-php .php

Edit

To make this answer more useful for others, the full configuration for php on apache2 is:

LoadModule php5_module libexec/apache2/libphp5.so

Or whatever your path is your php module. This is the default path which come with Mountain Lion. Al I had to do was uncomment it. This is followed in the apache2.conf file with:

<IfModule php5_module>
    AddType application/x-httpd-php .php
</IfModule>