MAMP

From ThinkyWiki

Jump to: navigation, search

Contents

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:

* JPEGSRC - http://www.ijg.org/files/
* LIBPNG source with config - http://www.libpng.org/pub/png/libpng.html
* LIBGD - http://www.libgd.org/Downloads
* PHP5 - http://www.php.net/downloads.php

Preparation

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 MACOSX_DEPLOYMENT_TARGET=10.5
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

Source: http://www.ijg.org/files/

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
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a

Install libPNG

Get "Source with config script": http://www.libpng.org/pub/png/libpng.html

cd libpng-1.2.22
./configure
make
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 http://hivelogic.com/narrative/articles/installing-mysql-on-mac-os-x

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
make
sudo make install
cd /usr/local/mysql
sudo ./bin/mysql_install_db --user=mysql
sudo chown -R mysql ./var

Install PHP

Download at http://www.php.net/downloads.php and find build help at http://blog.softboysxp.info/2008/05/27/compiling-64-bit-php-on-mac-os-x-leopard/

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 \
--without-pear

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 http://httpd.apache.org/download.cgi

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