I am starting from an installation with apache and PHP working: to get this point, read this

Here are the things i did :

  1. If you have already enabled PHP, disable it in apache config: open the file /etc/apache2/httpd.conf, put a comment before "LoadModule php5_module libexec/apache2/libphp5.so":
    #LoadModule php5_module local/php5/libphp5.so
  2. Get the PHP 5.2.5 Release 6 BETA (You can eventually get the future new versions in Marc's forum):
    curl -O http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz
    tar -xzf php5-*-beta.tar.gz
    
  3. If you have already installed the classic Marc Lyanage package, move it to your desktop:
    sudo mv /usr/local/php5 ~/Desktop/php5.old
  4. Put in the new package in place:
    sudo mv php5 /usr/local/
  5. Add a link to tell apache to use this version:
    sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf
  6. Configure is the file php.ini. You will find the file inside the new package. Edit /usr/local/php5/lib/php.ini. To contact the database MySQL with PHP you have to set the default socket name for local MySQL connects. Find the line starting with "mysql.default_socket = ", modify it to : "mysql.default_socket = /var/mysql/mysql.sock", save the file.
  7. Restart apache:
    sudo apachectl restart
  8. PHP should now be up and running. You can test it by dropping a file named test.php into your apache root folder directory (/Library/Webserver/Documents/). Into that file, write this line: <?php phpinfo() ?>. Now open up http://localhost/test.php in your web browser. You should see a status table with information about the PHP module.

In case you just want the classic Marc Lyanage PHP version with no GD, do this:

  1. make a link to help installation process :
    sudo ln -s /etc/apache2 /etc/httpd
    (if not you will get an error like "The following install step failed: run postflight script for Entropy PHP. Contact the software manufacturer for assistance")
  2. get entropy PHP package at http://www.entropy.ch/software/macosx/php/
  3. Install the entropy package (double-click on "entropy-php.mpkg")

References :