To install PHP on Mac OS X Lion 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.

You can start by downloading the latest source archive from Extract the source archive into a directory and use the Terminal to execute the following commands.

./configure --prefix=/usr/local/php5 \
  --mandir=/usr/share/man \
  --infodir=/usr/share/info \
  --sysconfdir=/etc \
  --with-config-file-path=/etc \
  --with-zlib \
  --with-zlib-dir=/usr \
  --with-openssl \
  --without-iconv \
  --enable-exif \
  --enable-ftp \
  --enable-mbstring \
  --enable-mbregex \
  --enable-sockets \
  --with-mysql=mysqlnd \
  --with-pdo-mysql=mysqlnd \
  --with-mysqli=mysqlnd \

To compile and install:

sudo make install

After installation, please add the following lines to your ‘httpd.conf’ at the end.

AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

Restart Apache and you’re ready to go.

As you might have seen from the ‘./configure‘ settings, your ‘php.ini‘ file will be located in ‘/etc‘.

If you need mcrypt or GD (graphics) look here.