Getting PHP working in Apache2 on Mac OS X Server

In OS X Leopard, out of the box (at least on the System I got access to) Apache2 is missing an AddHandler statement for PHP, so PHP won’t work if you just enable the module.  Here is how to fix that through Server Admin:

Check -> Web -> Settings -> Modules, php5_module is enabled.

In Settings -> MIME Types, check the following is present:

application/x-httpd-php      php

In Settings -> MIME Types -> Content Handlers, add the following:

php5-script      php

The resulting PHP entries in /etc/apache2/httpd.conf should look like this:

$ grep php httpd.conf
LoadModule php5_module libexec/apache2/libphp5.so
AddHandler php5-script php
AddType application/x-httpd-php php
AddType application/x-httpd-php-source phps
AddType application/x-httpd-php3 php3

You must be logged in to post a comment.