From ThinkyWiki

Jump to: navigation, search


Snow Leopard?

This article pertains to the full MAMP install on Leopard. For help installing PHP on Snow Leopard check out the article PHP on 10.6!

Needed Components

Before starting you will need these components:

* LIBPNG source with config -
* PHP5 -


Before starting these might help (I needed them):

sudo mkdir /usr/local/include
sudo mkdir -p /usr/local/man/man1

64 Bit Systems

On 64-bit Macs any binaries that include a 64 bit architecture will automatically load it when possible, and when they load a plugin or library they can only load the 64 bit arch. If the loaded binary doesn't have the 64-bit arch it fails. The Mac OS X version of Apache is built this way, so it can only load a 64-bit PHP. The same goes for mysql and all other dependencies, so before doing any builds you should export the following symbols:

export CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp"
export CCFLAGS="-arch x86_64 -g -Os -pipe"
export CXXFLAGS="-arch x86_64 -g -Os -pipe"
export LDFLAGS="-arch x86_64 -bind_at_load" 

Libiconv wasn't built properly until (AFAIK) 10.5.3, so you may need to build this too, unless your Leopard is fully up to date.

Install libJPEG


Untar then proceed with the install:

cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a

Install libPNG

Get "Source with config script":

cd libpng-1.2.22
sudo make install
sudo ranlib /usr/local/lib/libpng.a

LibXML May be needed?

cd libxml2
env CFLAGS="-O -g -arch i386 -arch ppc" LDFLAGS="-arch i386 -arch ppc"
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --with-html-dir=/usr/share/doc --disable-dependency-tracking
make -j3
sudo make install

Install MySQL

The following will get mysql built. It may be a good idea to mix in the export values from above before building to make sure you get the right architecture. Plus additional steps are required to create a launchd item. See more detailed instructions at

cd mysql-5.0.45
export CFLAGS="-O3 -fno-omit-frame-pointer"
export CXX=gcc
export CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-shared
sudo make install
cd /usr/local/mysql
sudo ./bin/mysql_install_db --user=mysql
sudo chown -R mysql ./var

Install PHP

Download at and find build help at

cd php-5.2.5
./configure \
--enable-cli \
--enable-exif \
--enable-fastcgi \
--enable-ftp \
--enable-mbregex \
--enable-mbstring \
--enable-sockets \
--enable-zip \
--infodir=/usr/share/info \
--localstatedir=/var \
--mandir=/usr/share/man \
--prefix=/usr \
--sysconfdir=/private/etc \
--with-apxs2=/usr/sbin/apxs \
--with-config-file-path=/etc \
--with-curl=/usr \
--with-gd \
--with-iodbc=/usr \
--with-jpeg-dir=/usr/local \
--with-kerberos=/usr \
--with-ldap=/usr \
--with-mysql-sock=/tmp \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-openssl \
--with-xmlrpc \
--with-xsl=/usr \
--with-zlib=/usr \

make -j3
sudo make install

Check the Shell PATH

Make sure that /usr/local/bin comes before /usr/bin in the shell's $PATH variable by editing ~/.profile, otherwise the wrong version of PHP will be invoked by shell scripts. To find out which copy of PHP will be invoked on the command-line, just use:

which php

If you want to be more Draconian about it (for scripts that explicitly use #!/usr/bin/php) then make a soft link:

cd /usr/bin
sudo mv php php-orig
sudo ln -s /usr/local/bin/php php

Install Apache2 From Source!

Get Apache 2 at

cd httpd-2.2.6
./configure --enable-layout=Darwin --enable-mods-shared=all
sudo make install
Personal tools