Neil Ang

Developer

A stunning likeness of Neil Ang
Hello world

PHP not working on fresh OS X install

Posted on

Twice recently I have formatted and started with a fresh install of leopard (10.5.6), and twice Apache has not loaded PHP correctly after enabling PHP in the config. It fails to add the .php file type, causing php files to download rather then display. This is due to execute permissions not being set on the /etc/apache2/other directory.

The solution

Here is what I needed to do to get PHP 5 working on a fresh install:

Using terminal:

open -a textmate /etc/apache2/httpd.conf

Locate and uncomment (remove the hash) from the PHP declaration (about line 115):

LoadModule php5_module libexec/apache2/libphp5.so

Save the httpd.conf, then back in terminal type:

sudo chmod 554 /etc/apache2/other/php5.conf

This will fix the PHP configuration file so it will load. You now need to restart the apache server:

sudo httpd -k restart

Everything should work as expected now.