Compiling PHP5.3.2 on MAMP

It was not easy to compile PHP5.3.2 on MAMP. First of all, you need to download httpd2.0.63 and PHP5.3.2. (I’m using MAMP 1.8.2 and Mac OSX 10.5.8)

MAMP is in /Application/MAMP already. You may want to backup that directory. You may need to edit srclib/apr/include/apr.h like “#define APR_HAS_SENDFILE 0” after run configure because get an error.

% tar jxvf httpd-2.0.63.tar.bz2
% cd httpd-2.0.63
% ./configure --enable-so --prefix=/tmp/httpd-2.0.63
% make
% make install
% cd /tmp/httpd-2.0.63
% cp -r build include /Application/MAMP/Library/

/Applications/MAMP/Library/bin/apxs returns error like “cannot open /Applications/MAMP/Library/build/ No such file or directory at /Applications/MAMP/Library/bin/apxs line 218.”, so compile apache first. Some include files (apr.h, os.h, httpd.h etc) are needed to compile PHP for apache module.

% tar jxvf php-5.3.2
% cd php-5.3.2
% ./configure --with-mysql=/Applications/MAMP/Library
% make
% make install

You may need to install some packages before compile PHP.

% port install libpng
% port install t1lib
% port install libintl
% port install gettext
% port install libxml

On my environment all port stuff will copy to /opt/local. Under /usr there’s OpenSSL 0.9.7l 28 Sep 2006. is located where you set –prefix for apache. It’s needed to copy to /Applications/MAMP/Library/modules.

You may also need to edit your php.ini. And, I recompiled some extensions. After everything is done, restart apache.

That’s it.

Upgrading PHP in MAMP

Finally it works with –with-iconv=shared,/Applications/MAMP/Library. Also I’ve upgraded MAMP1.8.4. –with-iconv-dir=/opt/local or /usr even /Applications/MAMP/Library doesn’t work and I get “ld warning: duplicate dylib” “Undefined symbols: _iconv_close” etc. It seems there’re many web pages that explain this error, but they don’t help my environment. The only thing I needed was to add –with-iconv and parameter should be shared.

I need iconv because Zend_Mail_Transport_Smtp returns error if PHP has no iconv: PHP Fatal error: Call to undefined function iconv_get_encoding() in Zend/Validate/Hostname.php

Apache is running with PHP, but receive an error though.
“dyld: lazy symbol binding failed: Symbol not found: _iconv_open”

OK. Now I installed libiconv from source. Then it WORKS.

% cd libiconv-1.13.1
% ./configure
% make
% sudo make install
./configure \
--with-iconv=/usr/local \
--with-iconv-dir=/usr/local \
--with-mysql=/Applications/MAMP/Library \
--with-apxs2=/Applications/MAMP/Library/bin/apxs \
--with-gd \
--with-jpeg-dir=/opt/local \
--with-png-dir=/opt/local \
--with-zlib \
--with-freetype-dir=/opt/local \
--prefix=/Applications/MAMP/bin/php5 \
--exec-prefix=/Applications/MAMP/bin/php5 \
--sysconfdir=/Applications/MAMP/conf/php5 \
--with-config-file-path=/Applications/MAMP/conf/php5 \
--enable-bcmath \
--enable-ftp \
--enable-gd-native-ttf \
--with-bz2=/usr \
--with-ldap \
--with-mysqli=/Applications/MAMP/Library/bin/mysql_config \
--with-sqlite \
--with-t1lib=/opt/local \
--enable-mbstring=all \
--with-curl=/Applications/MAMP/Library \
--enable-sockets \
--enable-bcmath \
--enable-soap \
--with-kerberos \
--enable-calendar \
--enable-exif \
--with-libxml-dir=/opt/local \
--disable-xmlreader \
--with-gettext=/opt/local \
--with-pdo-mysql=/Applications/MAMP/Library \
--with-openssl=/usr \
--with-xmlrpc \
This entry was posted in Tweak and tagged , , . Bookmark the permalink. Both comments and trackbacks are currently closed.