Blue Screen Of Duds

Where the alter ego of codelust plays

Installing Apache, PHP, MySQL, Postgresql on Mac OSX Leopard from source

with 14 comments

Update: Updated post (on December 11, 2008) here.


  1. We won’t be running any binary installations, all software will be compiled from source.
  2. The installation won’t make use of Fink or Darwinports either.
  3. These are instructions for the Intel Macs.
  4. Using this approach would mean that you will need to maintain the stack by hand.
  5. Use this information at your own risk.
  6. If you don’t want to go through all the trouble and use a binary installation, read this post.

The software stack we are going to install will be as follows:

Apache HTTP Server 2.2.6


PHP 5.2.5


MySQL 5.1.22 RC

Stock install

Postgresql 8.2.5

Stock install

We will also need to install the following software dependencies:

  1. Xcode (from the Leopard DVD or Apple Developer connection )
  2. Readline (
  3. Tidy (

This installation would not have been possible without help from the following websites:

  1. Installing Readline on OSX without using Fink or Darwinports
  2. Workaround for Tidy’s platform.h problem
  3. Installing the GD library on OSX Leopard

Now to the installation:

Install Xcode

Install MySQL

Download mysql-5.1.22-rc.tar.gz from the website
$/configure --prefix=/usr/local/mysql
$sudo make install

Update: The steps did help me in getting to install the server, but on start up it did give certain location-specific errors.

As Hill has pointed out in the comments, has not released a version of their software for Leopard, but I got 5.1.22 RC to install, run and connect from PHP without any hassles following the instructions in one of the links he had kindly posted.

Install Readline

Download the source from
There are bugs with the installation as elaborated in this link with workarounds:
$make static
$sudo make install static

Install Postgresql

Download the source from
$./configure --with-prefix=/usr/local/postgresql
$sudo make install

Install GD

Follow the instructions at

Install Tidy

Download Tidy source

This will throw up errors that can be fixed by following these instructions
$sudo make install

Install Apache

$CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk"
$./configure \
--prefix=/usr/local/apache2 \
--enable-authn-dbm \
--enable-ssl \
--enable-dav \
--enable-info \
--enable-speling \
--disable-userdir \
--enable-rewrite \
--enable-so \

if you get an apr.h error regarding sendfile, edit the apr.h file in srclib/ext/includes and change APR_HAS_SENDFILE to ‘0’

$sudo make install

Install PHP

$./configure \
--with-apxs2=/usr/local/apache2/bin/apxs \
--prefix=/usr/local/php \
--with-pgsql=/usr/local/postgresql \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-tidy=/usr \
--with-curl=/usr/bin \
--with-curlwrappers \
--with-openssl-dir=/usr/bin \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/X11R6 \
--with-zlib-dir=/usr \
--with-freetype-dir=/usr/X11R6 \
--enable-mbstring \
--with-xpm-dir=/usr/X11R6 \
--with-pdo-pgsql=/usr/local/postgresql \
--with-pdo-mysql=/usr/local/mysql \
--with-xsl=/usr/bin \
--with-ldap \
--with-xmlrpc \
--with-iconv-dir=/usr \
--with-snmp=/usr --enable-exif \
--enable-calendar \
--with-bz2=/usr \

$sudo make install

And that’s all folks!


Written by shyam

December 23, 2007 at 12:23 pm

Posted in Apache, Apple, Leopard, Mysql, OSX, PHP

Tagged with , , , , ,

14 Responses

Subscribe to comments with RSS.

  1. Hi Shyam

    I’m Hill from

    Thank you very much to link my post to your site

    There’s one thing I just don’t understand: It’s really necessary to re-install a new apache2 and php5 again? they are pre-installed in Leopard, they are just not installed by default, I have to admit the pre-installed version of apache2 and php5 are a little jumbled but … that’s cool anyway.

    and you point out that, for the installation of GD, users can follow the instructions at ( my post ). but the tutorial at is telling others how to install GD library and integrate it into the PRE-INSTALLED PHP5 ON LEOPARD, not a fresh installed version of php5. I mean, a new fresh installation of php5 with GD support is more easier than what I posted in my site.

    please look your command lines for installing PHP5,
    ./configure \

    –with-gd \

    sudo make install

    if you don’t installed libjpeg, the installation of php with GD will show you an error. so , I propose you to write TWO tutorials:
    1.install apache2 php5 mysql postgresql on leopard
    2.reinforce pre-installed php5 and install mysql postgresql on leopard.


    December 23, 2007 at 2:46 pm

  2. oh, yes, I forgot on thing. has not released an appropriate version of mysql for Leopard. We have to choose the one for OS X 10.4, so, we have to do something after the installation.
    please check the 2 posts following:


    December 23, 2007 at 2:54 pm

  3. Hello Hill,

    I wanted to compile my own PHP/Apache for a few reasons

    1) The Leopard install does not have the Postgresql extension enabled on it
    2) I do a bit of XPATH wrangling and can’t do without the Tidy extension, which was the only reason that I had to turn away from the Entropy dist.
    3) I’ve always rolled out my own and like things tucked away neatly in /usr, it is an old habit and our production servers run with the same layout

    Your instructions for integrating GD into the pre-installed PHP on Leopard worked for me, just that I made the changes within the source tree that I was using to build PHP and I get the same output on GD with phpinfo() as you do.

    I guess I need to clarify that you’ll need to adapt the steps mentioned there.


    December 23, 2007 at 3:05 pm

  4. Sheesh, I’d left MySQL at the build and install, which it did successfully. Let me poke around with the links and update the post as soon as I can get it running.

    And thank you for your comments!


    December 23, 2007 at 3:13 pm

  5. […] Running Apache 2, PHP5 (Entropy) with Postgresql on Leopard December 14, 2007 Update: New post on installing from source here. […]

  6. I had a problem where MySQL thought that it was a binary package while it was not. I tried the 5.1 RC and also the 5.0.45 tar.gz packages.

    I’m new to server administrating in UNIX but I’m not in Windows Platform. Mac OS X Leopard is also my main OS since I did a recent switch and have been happy.

    For some reason the default Apache on Leopard doesn’t work even if I enable web sharing.

    Also it seems kinda complicated for me to do “enable-mbstring .. etc” options since there are a lot. On Windows, after I installed apache , php, mysql I configured them through the .conf files. Can I just use “./configure –prefix=/usr/local/” and configured them through the manuals?

    Email me back.

    Thank you.

    Jonathan Vasquez

    January 11, 2008 at 6:55 am

  7. helo,

    ran the above step by step on macosx 10.5.1 – with apache 2.2.6, php5-2-4, postgre 8.2.6. Tidy, GD are also installed.

    last errors on make for apache were as follows [fix below]
    I did make & make install as ‘root’ btw if it makes a difference
    ab.c: In function ‘start_connect’:
    ab.c:1150: warning: passing argument 2 of ‘BIO_set_callback_arg’ from incompatible pointer type
    /usr/share/apr-1/build-1/libtool –silent –mode=link gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/usr/lib -o ab ab.lo /usr/local/httpd-2.2.6/srclib/pcre/ -L/usr/lib -R/usr/lib -laprutil-1 -lsqlite3 -lexpat -liconv -L/usr/lib -R/usr/lib -lapr-1 -lpthread -lssl -lcrypto -L/opt/local/lib -lz
    Undefined symbols:
    “_BIO_set_callback_arg”, referenced from:
    _start_connect in ab.o
    “_BIO_get_callback_arg”, referenced from:
    _ssl_print_cb in ab.o
    “_SSL_CTX_set_info_callback”, referenced from:
    _main in ab.o
    “_BIO_set_callback”, referenced from:
    _start_connect in ab.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make[2]: *** [ab] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all-recursive] Error 1

    can anyone help here? what I did to fix it temporarily is eliminate the SSL additions into apache by removing -enable-ssl & -with-ssl=/usr/bin … then all was fine. any clue why this fixed it? i don’t need SSL for the moment so it is OK.

    TIA for any help at all


    January 15, 2008 at 9:40 am

  8. Seriously, who gets off on this?? Isn’t there a simpler way to just get this crap to work? I’m such an Apple fan but honestly, PCs are kicking the Mac’s butt on this stuff and this kind of crap isn’t helping. Why is there 5 billion blogs out there trying to get 3 or 4 software packages to run together in order to create a web server?? This stuff has been around for 10 years now. Give me a break.


    February 3, 2008 at 11:36 am

  9. Dear Ugh,

    Apple does provide you with with a simpler way, just use the default packages, point and click here and there and you are ready to go.

    I have a specific requirement, which requires you to go out your way.

    You don’t need to do this, there is an easier way to do this.


    February 3, 2008 at 12:33 pm

  10. Dear Shyam,

    I experience the same problem as zolo is reporting:

    ab.c: In function ‘start_connect’:
    ab.c:1145: warning: passing argument 2 of ‘BIO_set_callback_arg’ from incompatible pointer type
    /usr/share/apr-1/build-1/libtool –silent –mode=link gcc -L/usr/lib -L/usr/local/ssl/lib -o ab ab.lo /Users/dwikler/Projects/eID/apache/httpd-2.2.4/srclib/pcre/ -L/usr/lib -R/usr/lib -laprutil-1 -lsqlite3 -lexpat -liconv -L/usr/lib -R/usr/lib -lapr-1 -lpthread -lssl -lcrypto
    Undefined symbols:
    “_BIO_set_callback_arg”, referenced from:
    _start_connect in ab.o
    “_BIO_get_callback_arg”, referenced from:
    _ssl_print_cb in ab.o
    “_SSL_CTX_set_info_callback”, referenced from:
    _main in ab.o
    “_BIO_set_callback”, referenced from:
    _start_connect in ab.o
    ld: symbol(s) not found

    Running MacOSX 10.5, using latest SSL (0.9.8g)
    I do need to include SSL as this is the real purpose of my installation.
    Any clue about these link errors ?

    Thank you



    February 9, 2008 at 2:11 pm

  11. I found that excluding tidy helped me. Also, because I was using the default install of Apache on Leopard, I had to change the APXS path. my configure command is below:

    ./configure \
    –with-apxs2=/usr/sbin/apxs \
    –prefix=/usr/local/php \
    –with-mysql=/usr/local/mysql \
    –with-mysqli=/usr/local/mysql/bin/mysql_config \
    –with-curl=/usr/bin \
    –with-curlwrappers \
    –with-openssl-dir=/usr/bin \
    –with-gd \
    –with-jpeg-dir=/usr/local/lib \
    –with-png-dir=/usr/X11R6 \
    –with-zlib-dir=/usr \
    –with-freetype-dir=/usr/X11R6 \
    –enable-mbstring \
    –with-xpm-dir=/usr/X11R6 \
    –with-pdo-mysql=/usr/local/mysql \
    –with-xsl=/usr/bin \
    –with-ldap \
    –with-xmlrpc \
    –with-iconv-dir=/usr \
    –with-snmp=/usr –enable-exif \
    –enable-calendar \
    –with-bz2=/usr \

    Website Design Cambridge

    February 12, 2008 at 2:02 am

  12. I could not get gd to work, did not both with tidy, nor do I want MySQL. Only PostgreSQL. Hence my configure command turned out to be:

    ./configure -with-apxs2=/usr/local/apache2/bin/apxs -prefix=/usr/local/php5 -with-pgsql=/Library/PostgreSQL8 -with-curl=/usr/bin -with-curlwrappers -with-openssl-dir=/usr/bin -with-jpeg-dir=/usr/local/lib -with-png-dir=/usr/X11R6 -with-zlib-dir=/usr -with-freetype-dir=/usr/X11R6 -enable-mbstring -with-xpm-dir=/usr/X11R6 -with-pdo-pgsql=/Library/PostgreSQL8 -with-xsl=/usr/bin -with-ldap -with-xmlrpc -with-iconv-dir=/usr -with-snmp=/usr -enable-exif -enable-calendar -with-bz2=/usr -enable-debug

    Thank you guys. This thread helps. (And no, nobody gets off on this type of thing. If the people up there developing for us all, could afford to please ALL of us, and do all these for us before shipping their products, then maybe they won’t be that rich. We just have to help each other, poor bugger us. Cheers!)

    gheekeong kang

    March 6, 2008 at 5:39 pm

  13. Is there a way to figure out what “configure” options Apache is installed with NOW?

    All of these four:

    (1) PHP
    (2) Apache
    (3) Postgresql
    (4) MySQL

    Seem to require the “.configure” option. Can someone recommend what we should do? What’s the recommended setting?

    All I want to do is have the combo of the above working so that I can start testing from my “http://localhost”. Can anyone please please please help? I mean, it’s not just that we install these separately. They need to work together. (PHP needs to recognize pg_connect and mysqli_connect). Thanks!!


    August 27, 2008 at 3:33 pm

  14. Wow. Incredible information.

    I’ve used it to create a soup-to-nuts install, from source, of Apache 2.2.11, PHP 5.2.9, and Postgres 8.3.7 for MacOS X – Leopard (I’m using 10.5.7).

    Basically, it’s a single Makefile and a set of patches that allows most of the software to get installed to /usr/local, apache to /usr/local/a2, postgres to /usr/local/pgsql, and php to /usr/local/php. The Makefile will attempt to download the source tarballs if they don’t exist in the working directory, and builds each from scratch.

    99% of the install is interaction-free. At the very end, there are some prompts for PEAR, to which the user should simply press [enter] (to select the default setting). Afterwards, when the software packages are all finished being installed, the Makefile patches a system file in /System/Library/LaunchDaemons (org.apache.httpd.plist) so that apache can be started and stopped from System Preferences.

    Works beautifully.

    You can get the link from my blog:; unpack it, and read the README for usage directions.

    * * *

    BE FOREWARNED…The installation all takes places as root (via sudo). I hope it works for you (and you can review everything, since it’s all just text–the README, Makefile, and patches), but if it doesn’t, I take no responsibility for mucking up your machine–please know what you’re doing.


    May 30, 2009 at 2:05 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: