Upgrading Native PHP on MacOSX Mountain Lion

This tutorial provides instructions on how to upgrade the native PHP installation on MacOSX Mountain Lion to the lastest stable version of PHP.

Prerequisites

Use Homebrew to install the prerequisites of PHP. Execute the following commands in your terminal of choice:

brew install libjpeg
brew install pcre
brew install libxml2
brew install mcrypt
brew install icu4c

Possible Errors

Error 1:

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

Solution 1:
You will need to download and compile the IMAP source code. Which is available here.

tar xzvf imap-2007e.tar.gz
sudo mv ~/Downloads/imap-2007e /usr/local/imap-2007
cd /usr/local/imap-2007
make osx
sudo cp c-client/c-client.a c-client/libc-client.a

Compile and Install PHP

Download and extract the PHP source from here.

tar xzvf php-5.4.x.tar.gz
cd ~/Downloads/php-5.4.11

Run the configure command

./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--with-apxs2=/usr/sbin/apxs \
--enable-cli \
--with-config-file-path=/etc \
--with-libxml-dir=/usr \
--with-openssl=/usr \
--with-kerberos=/usr \
--with-zlib=/usr \
--enable-bcmath \
--with-bz2=/usr \
--enable-calendar \
--with-curl=/usr \
--enable-dba \
--enable-exif \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-icu-dir=/usr/local \
--with-iodbc=/usr \
--with-ldap=/usr \
--with-ldap-sasl=/usr \
--with-libedit=/usr \
--enable-mbstring \
--enable-mbregex \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--without-pear \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/var/mysql/mysql.sock \
--with-readline=/usr \
--enable-shmop \
--with-snmp=/usr \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-tidy \
--enable-wddx \
--with-xmlrpc \
--with-iconv-dir=/usr \
--with-xsl=/usr \
--enable-zip \
--with-imap=/usr/local/imap-2007 \
--with-kerberos \
--with-imap-ssl \
--enable-intl \
--with-pcre-regex \
--with-pgsql=/usr \
--with-pdo-pgsql=/usr \
--with-freetype-dir=/usr/X11 \
--with-jpeg-dir=/usr \
--with-png-dir=/usr/X11

Now, that the configure has executed without any errors continue by executing the make test command.

make test

Then finally execute the make install command to install PHP.

make install

If all goes well you should have upgraded your native PHP installation to the new version. To confirm that you the new version of PHP, execute the following command in a terminal window:

php -v

You should see an output similar to this:

PHP 5.4.x (cli) (built: Dec 21 2012 15:28:12)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

References:

Installing PHP 5.4 on Mac OS X Mountain Lion from Source
Snow Leopard PHP and IMAP Support
PHP Installation On Mac
Installation failed with icu-config error on Mac OS X 10.8
Upgrading the Native PHP Installation on OS X Mountain Lion

Leave a comment