Source install Apache 2.2.13 + PHP 5.3 + Snow Leopard
As most of you know Snow Leopard (SL) is based on 64-bit architecture, and when you install Xcode 3.2 that comes with SL the gcc compiler defaults to 4.2.1 and seems to default to x86_64 not i386.
Thanks to the following websites:
- http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/
- http://projects.serenity.de/php/
- http://dawsdesign.com/drupal/comment/reply/30#comment-form
- http://pixelchimp.net/blog/pixel-chimp/reverting-php-53-5210-snow-leopard(most helpful for finding the other sites)
- http://www.kevinkorb.com/post/24
- http://www.latko.org/2009/01/31/compiling-64-bit-apachephp-on-mac-os-x-1056/
- http://www.gen-x-design.com/archives/recompiling-php-5-3-on-snow-leopard-with-freetype-support/
My Solution:
Follow the instructions on hivelogic.com for installing MySQL on SL
Install Apache 2.2.14 via instructions on http://projects.serenity.de/php/ - it uses 2.2.13 but replacing a 13 with a 14 is easy right? ;) After Apache (x86_64) is installed do the following:
cd /usr/local/apache2/bincp httpd /usr/sbin/cp apachectl /usr/sbin/
As mentioned on http://www.kevinkorb.com/post/24
Compile and install packages (freetype,gettext,libjpeg,libpng,mcrypt,mhash,etc) mentioned right after the Apache install instructions on http://projects.serenity.de/php/ until IMAP, if you need IMAP then try the instructions mentioned in the url above but I didn't install since I didn't need it.
NOTE: These all compiled as x86_64 with the exception of libpng which required the the following to be compiled as 64-bit:
*export CFLAGS="-arch x86_64" ./configure
This is where all the head banging on a desk and trial and error occurred. The installation of PHP 5.3.0. The biggest issue is with ICONV which has linking issues. I searched all over Google and some others were successful by editing the iconv.c file and the Makefile by adding -lresolv to the EXTRA_LIBS= after the ./configure string was executed. I was not so lucky, but still needed to make the edits for the --without-iconv parameter to work. Also --with-xmlrpc would not work. For the iconv hacks please refer to this blog entry
So here is my ./configure string:
./configure --prefix=/usr/local/php5--without-iconv--with-apxs2=/usr/local/apache2/bin/apxs--enable-pdo--with-gd --with-zlib --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-libxml-dir=/usr/local --with-curl --with-mcrypt --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-mhash --with-libxml-dir=/usr/local --with-t1lib=/usr/local --with-xsl --with-freetype-dir=/usr/local --with-gettext --with-bz2=/usr --with-openssl=/usr --enable-bcmath --enable-calendar --enable-cgi --enable-exif --enable-ftp --enable-gd-native-ttf --enable-mbstring --enable-soap --enable-sqlite-utf8 --enable-cli --enable-wddx --enable-zipmakesudo make install
On a final note, I downloaded PHP-5.3.2-dev (http://snaps.php.net/) and it seems to have fixed the linking issues with ICONV and XMLRPC. The only changes that I've made to the above ./configure string were replace --without-iconv with --with-iconv=/usr/local and added --with-xmlrpc. This is a dev version and I am sure that it still has bugs so use at your own discretion.
If you are having any issues please feel free to comment and I will try to help!
See here:http://bugs.php.net/bug.php?id=49267
Basically:
Add "-lresolv" to MH_BUNDLE_FLAGS, EXTRA_LDFLAGS andEXTRA_LDFLAGS_PROGRAM in "Makefile"
Change "ext/iconv/iconv.c"
#define iconv libiconv
to:
#define iconv iconv
As they say, worked for me.
In apache source directory
cd srclib/apr-util/xml/expat./configure# OR ./configure --prefix=/{{YOURDIR}}/apache/source/httpd-2.2.22/srclib/apr-util/xml/expat/sudo make install# OR make install
Remember to clean up your previous apache install after make install failed
cd {{YOURDIR}}/apache/ls -larm -r binrm -r buildrm -r includerm -r lib