Quantcast
Channel: Bit Melt Blog
Viewing all articles
Browse latest Browse all 25

Compiling PHP 5.4.6 On OS X Mountain Lion

$
0
0
Mountain Lion came out, and still no PHP 5.4. It removed X11 though, which I used on Lion for the PNG and FreeType libraries when I compiled PHP 5.4 there. Instead of installing X11, I just compiled and installed the missing libraries this time. Command line tools have to be installed separately from inside XCode Preferences -> Downloads.

Here's how to install PHP 5.4.6 on Mountain Lion. I made a standalone installation, without affecting the Apache server that is already on the machine. PHP 5.4 has a built-in web server, so I don't need Apache on my laptop for development.

First, download, compile and install libjpeg. I downloaded it from http://www.ijg.org/files/, specifically the jpegsrc.v8d.tar.gz. Compile and install:

./configure --prefix=/usr/local/libjpeg8d
make
sudo make install

Download and install libfreetype from http://freetype.sourceforge.net/download.html#stable :

./configure --prefix=/usr/local/libfreetype2410
make
sudo make install

Download and install libpng from http://www.libpng.org/pub/png/libpng.html:

./configure --prefix=/usr/local/libpng1512
make
sudo make install

Finally, configure, compile and install PHP:

./configure \ 
  --prefix=/usr/local/php546 \ 
  --with-openssl \ 
  --with-pcre-regex \ 
  --with-zlib \ 
  --enable-bcmath \ 
  --with-bz2 \ 
  --enable-calendar \ 
  --with-curl \ 
  --enable-exif \ 
  --enable-ftp \ 
  --with-gd \ 
  --with-jpeg-dir=/usr/local/libjpeg8d \ 
  --with-png-dir=/usr/local/libpng1512 \ 
  --with-freetype-dir=/usr/local/libfreetype2410 \ 
  --enable-gd-native-ttf \ 
  --with-ldap \ 
  --with-ldap-sasl \ 
  --enable-mbstring \ 
  --with-mysql \ 
  --with-pdo-mysql \ 
  --with-mysqli \ 
  --with-libedit \ 
  --enable-pcntl \ 
  --enable-shmop \ 
  --with-snmp \ 
  --enable-soap \ 
  --enable-sockets \ 
  --enable-sysvmsg \ 
  --enable-sysvsem \ 
  --enable-sysvshm \ 
  --with-tidy \ 
  --enable-wddx \ 
  --with-xmlrpc \ 
  --with-xsl \ 
  --enable-zip

make
sudo make install

I also used pecl to install the MongoDB driver, but that made me realize that Mountain Lion did not have autoconf installed. So I downloaded it from http://ftp.gnu.org/gnu/autoconf/, compiled and installed it:

./configure --prefix=/usr/local/autoconf269
make
sudo make install
sudo sh -c 'echo "/usr/local/autoconf269/bin"> /etc/paths.d/autoconf'

That last line adds this autoconf to the PATH for all users on the system, but you'll need to open a new Terminal to see it.

Then install the MongoDB driver:

sudo /usr/local/php546/bin/pecl install mongo
sudo sh -c 'echo "extension=mongo.so">> /usr/local/php546/lib/php.ini'

Viewing all articles
Browse latest Browse all 25

Trending Articles