Mac OS X 10.9 Mavericks and PHP

I was waiting the official release of Mavericks since about half a year. I was positively surprise to find out the update came free of charge. So I updated my Mac OS the moment the update was made available on AppStore. It was no surprise to see the upgraded versions of PHP, Ruby, Python, mysql and so on. It was nevertheless no surprise to see that the PHP configuration would not completely meet my development requirements. One of the most frustrating features missing from the PHP installation was the Intl package. I can hardly understand how Apple would miss compiling PHP with the Intl package, as this is required by the Locale class (yes, internationalisation is the key word here). One could say PECL will handle that for you automatically. Been there, done that, failed! Reason: PECL does nothing else but download the package and tries to compile it against the php sources. But a freshly installed MacOS has almost no sources for any of the software installed on your machine. And since we don’t have any official package manager, we should download, configure and compile ourselves everything we need. There are a lot of users who would advocate using an unofficial package manager (like mac ports or homebrew) but I’m a geek, I’d rather compile everything myself and have some more fun while I’m at it. Also, since it’s a fresh OS realease/update, I’m not sure if those package manager are still working flawlessly Now, let’s start our little adventure: downloading sources and compiling PHP and its modules. I’ll present you here a list of links where you can download the sources of the packages that come with Mavericks.

  • PHP 5.4.17 (or, since you’re at it, why not upgrade your PHP version to the latest stable release PHP 5.5.5 ?)
  • Apache 2.2.24
  • Open SSL (Package is required since the default compilation options of PHP on Mavericks contains –with-openssl .I recommend downloading the latest stable version)
  • Zlib ( –with-zlib )
  • BZIP2 ( –with-bz2 )
  • cURL ( –with-curl )
  • iconv ( –with-iconv )
  • LDAP ( –with-ldap=/path/to/executable )
  • BerkeleyDB ( required by LDAP installation )
  • SASL2 ( –with-ldap-sasl=/path/to/executable )
  • LibEdit ( –with-libedit=/path/to/executable )
  • LibTidy ( –with-tidy )
  • autoconf  (required to compile LibTidy )
  • automake (required to compile LibTidy )
  • libtoolize ( required to compile LibTidy )

Each package comes with a readme or install.txt file which explains how to compile it.
Almost all of them only require a

sudo make install

In some cases you would also have to specify a path there to install the library. Everybody recommends using /usr/local for compiling/installing yourself anything you want to compile manually. This also has a reason. If by any chance Apple decided to support ONLY the version and specific configuration delivered with the OS, you would be able to switch back to it without having to re-install the hole operating system.

Before compiling PHP, first check which is the compile option used for the OS-default installation of PHP.
Try to stick to that compile options and add new options that you require, or remove the options that you know for sure it would create problems for your project ( I’ve worked on a project that specifically required to disable the suhosin plugin for PHPm which comes enabled by default to most of the PHP installations )

Now run the ./configure command with all the options you need, followed by “make” and “sudo make install”.
Giving that you had a successful compilation, you will now have PHP freshly re-configured/re-installed and you can proceed further with your project’s development.
After this freshly re-compile, you can now also use PECL to install new packages and modules.

This is not a complete guide, but I will try to improve it bit by bit.
If you have any suggestions or if you tried the above suggestions and encountered errors, please send me a message and I will try to cover those problems here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Blue Captcha Image