PHP5 is already installed on Leopard by default - all you have to do is turn it on.

First, turn on web sharing - go to System Preferences->Sharing and make sure the ‘Web Sharing’ option is turned on.


Next, open the apache config file in a text editor using sudo.

$ sudo vi /etc/apache2/httpd.conf

Search for this line:

#LoadModule php5_module libexec/apache2/

And un-comment it by removing the ‘#’ at the start of the line:

LoadModule php5_module libexec/apache2/

The restart apache:

$ sudo apachectl restart

To test if it is working properly, make a file in the Sites folder for your user called test.php (in my case this is /Users/dave/Sites/test.php ) containing the following:

<?= phpinfo() ?>

Now if you go to http://localhost/~YOUR_USER_NAME/test.php (note the ‘~’ character before your username - it’s important), you should see something like this:

PHP Info