Tag Archives: Mac OS X

PHP 5.4 on OS X Mountain Lion

Installing PHP 5.4 on Mac OS X Mountain Lion from Source

Here is how to install (or update) PHP 5.4 on Mac OS X Mountain Lion from source. This walkthrough is an extension of Upgrading the Native PHP Installation on OS X Mountain Lion. So first follow that, and if you come across any issues during the ./configure part of PHP installation, then come back here. This is what you will get at the end:

PHP 5.4 on Mac OS X

Here are the step-by step instructions that I followed to get PHP installed from source on Mac OS X Mountain Lion:

Step 1: Follow the Yellow Brick Road

Follow Upgrading the Native PHP Installation on OS X Mountain Lion (tutorial 1). Ideally, this link would be the only article you have to go through to setup PHP 5.4 on OS X Mountain Lion. In my case, it wasn’t. So we move to step 2, where I encountered the first error during ./configure part of PHP installation. The rest of this walkthrough assumes that you have followed the walkthrough from the original tutorial up till the ICU installation section, right before the “Installing” heading.

Step 2: Install libpng to tackle: configure: error: png.h not found.

Upon executing the following:

$ ./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  \
--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

It ended with the following lines:

checking for jpeg_read_header in -ljpeg... yes
If configure fails try --with-vpx-dir=<dir>
configure: error: png.h not found.

I tackled this by installing libpng through homebrew (you should have homebrew installed from the earlier step in the original tutorial):

$ brew install libpng

Step 3: Install freetype to tackle: configure: error: freetype.h not found.

Executing ./configure line again ended with another error:

configure: error: freetype.h not found.

Tackled it by installing freetype:

$ brew install freetype

Step 4: Tackling: configure: error: utf8_mime2text() has new signature …

Executing ./configure again, it threw a new error this time:

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

This took me the longest to solve! I tried the following:

$ brew install openssl

But that didn’t solve the problem. The error turned out to be related to the PHP IMAP extension, for which, as I found out, we require to compile IMAP from source.

Step 4.1: Compiling IMAP from Source on OS X Mountain Lion

I followed Step 1 from Snow Leopard PHP and IMAP Support article to get IMAP compiled on my Mac (no need to follow the rest of the steps), which made the error in step 4 go away, but introduced a new one.

Step 4.2: Helping OS X find libc-client.a

Now the new error that I received when executing ./configure was:

configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.

For this, I got a little help from PHP IMAP support in Mac OS X Lion without recompiling PHP: I executed the following (while in the /usr/local/imap-2007 folder):

$ sudo cp c-client/c-client.a /usr/local/lib/libc-client.a

This fixed the error.

Step 5: Do you want PHP with International Support?

Yet another error upon executing ./configure. Installing PHP manually on Mac OS X is such a pain!

checking for location of ICU headers and libraries... not found
configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.

Turns out that this resulted from a a step I skipped from the original tutorial, which walked through installing ICU for enabling international support. If you are getting this error, make sure you followed that step. However, if you don’t really want international support in PHP on your system, you can remove the –enable-intl option while running ./configure. I did the latter and finally got through the ./configure command!

Milestone Reached: Configured successfully!

Upon successful execution of ./configure, you will see the following:

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h
config.status: executing default commands

Yay!

Oh wait, there is more to do before PHP 5.4 is installed on OS X Mountain Lion.

Step 6: Make PHP

Followed the next part in tutorial 1, which involved running:

$ make test

The tutorial said that it will take up to 30 minutes, so we need to wait. After a while, the process ended with the following:

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.

This probably means success as far as make is concerned, so I went ahead with the next part of the tutorial. It will also ask you to send the test result to PHP folks and ask for your email address if you choose to.

Step 7: Install PHP

$ sudo make install

It ended quickly. Looks like everything went fine.

Step 8: Check PHP version to make sure you got everything right!

Let’s check the PHP version:

$ php -v

This resulted in:

PHP 5.4.10 (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

Yayy!! Installing PHP 5.4 on Mac OS X, or updating it, was not easy, but in the end you should have PHP updated to version 5.4, just like I did! While doing it, we gained the experience of building, compiling and installing a software from source. It was worth it.

Celebrate! 

Highly Compelling Reasons for Switching to an Apple Mac

Interesting experience of why Rob Christensen, from Adobe AIR product development/management team, decided to switch to Apple iMac in his post Six reasons why he made the switch. His reasons are quite compelling and I agree fully with what he has to say against Microsoft Windows and in favor of Apple Mac. My most compelling reasons, from Rob’s post, for switching to an Apple Mac would be:

Apple. In the past year, I’ve purchased two iPod Shuffles: one for myself and one for my wife. When I thought I had lost my Shuffle recently (for the second time), I decided to upgrade to an iPod Nano. It’s an absolutely incredible piece of technology. … The allure of hooking up iPod hardware to a Mac is difficult to ignore. Also, Apple’s decision to extend the hardware capabilities of the iMac has really put it in direct competition with Dell’s flagship desktop products like their XPS line.

Apple, and Steve Jobs, is an inspiration. I had the first generation iPod Nano and it was awesome! I love Apple and what it is creating. Correction: Innovating!

Media Management. It’s truly shocking to me that Microsoft has not improved the user experience with Windows Media Player (WMP). Something about the design of WMP has always felt exceedingly video centric as opposed to library focused. Playing an .mp3 will force most of the screen to be taken over by an annoying visualization. … In addition, the lack of basic photo management in Windows has been the source of tremendous grief.

I have to agree with Rob’s WMP experience. Though I have been a Windows Media Player user since long (I was hooked to the ex-king Winamp before that, during its 1.x and 2.x versions reign, and Sonique too – ah what a super cool player that was!), but since my WMP music database has been wiped out (the database itself, and not the music files) after the Vista of my laptop’s pretty Windows was shot down by a vicious virus and I installed it anew, I am trying out a new media player: the open source Songbird. And it’s pretty good.

Most applications are now on the Mac. Nearly all of the applications I use are now available on the Mac such as Firefox, the Creative Suite (Dreamweaver, Flash, etc.), Office, Stellarium, AIM, Google Earth, etc. If the tools you use and depend on are portable, then it makes it even easier to make the switch.

That’s definitely a compelling reason. And on top of that, if a Windows application has not yet been ported to the Mac, one always has the option of Boot Camping to Windows. Tada! Nice one, Apple.

Now all these reasons make me crave for an Apple iMac/Macbook all over again! I hope I’ll be able to afford one soon.