To install PHP on Mac OS X Leopard there are, just as with Apache, several options one could use. I’ve chosen the most simple setup that will get most PHP based applications running that we need for the mailserver and such. Please remember that this is the 32 bit mode installation which requires a 32 bit MySQL installation otherwise you will get compiler errors.
You can start by downloading the latest source archive from www.php.net. Extract the source archive into a directory and use the Terminal to execute the following commands.
To compile and install:
sudo make install
If the install fails because of a PEAR error like:
[PEAR] Console_Getopt: upgrade to a newer version (1.2 is not newer than 1.2)
warning: pear/PEAR dependency package “pear/Archive_Tar” installed version 1.1 is not the recommended version 1.3.1
[PEAR] PEAR: commit failed
You’ll need to upgrade the PEAR package on your machine. Save the script at http://pear.php.net/go-pear to your desktop as go-pear.php and execute ‘sudo php go-pear.php’. Just answer the questions when needed, most can be answered by just pressing the enter button. The most important one is to change the installation prefix from ‘
/usr‘ to ‘
/usr/local/php5‘ and that is it. Try to rerun the ‘sudo make install’ in the PHP source directory and it should work.
After installation, please check if the your ‘httpd.conf’ has been updated for the PHP extension and if the module is being loaded. Your ‘httpd.conf’ file should have the following lines:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
Restart Apache and your ready to go.
As you might have seen from the ‘
./configure‘ settings, your ‘
php.ini‘ file will be located in ‘
Next step: Installing the Mailserver