Recompiling PHP 5.3 On Snow Leopard With Freetype Support

OK, so this article probably doesn’t have a ton of mass appeal, but since upgrading to Snow Leopard I’ve run into a major issue with the way PHP is compiled in this distribution. Overall, I’m incredibly satisfied with the way everything’s set up by default in Snow Leopard (PHP 5.3 with bundled GD, mysqlnd, etc.), but the big glaring hole in everything was the lack of Freetype support. I’ve been working on a graphing library for my day job, and as such found the need to place text in my images (strange, right?). Anyway, I finally took the plunge and figured out how to get that sucker compiled in there. Here’s what you have to do…

Basically, what we’re going to do is recompile PHP 5.3 exactly the same as it came, but with proper Freetype support. Before we get into anything, here’s a few disclaimers:

  • This worked for me… it may not work for you. If you never make it to the “make install” step of the PHP build, you won’t screw up your system so you can feel relatively safe trying this. However, I can’t support you if something goes wrong. Don’t worry tho, you shouldn’t run into many issues :)
  • The steps in this tutorial are munged together from various other sources on the web. I’d like to credit these people if possible, but I don’t have a list of all my various sources… if your stuff is on here, lemme know and I’ll make sure you’re properly credited and linked to :)
  • You MUST have the xcode developer tools installed for any of this to work. You’ll know right away if you don’t, as “make” will be an unknown command for you. These are on your Snow Leopard install DVD if you don’t have them…

OK, moving on…

Download Source Files

We’re going to need to grab a few things to get started. So, fire up a terminal, and type in the following:

sudo mkdir /src
sudo chown [your username]:staff /src
cd /src
mkdir pcre
mkdir php
cd pcre
curl ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz -O
cd ../php
curl http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-53/php-5.3.0.tar.bz2 -O

What we’ve got is the PHP 5.3 package from Apple, and the PCRE library… everything else we need is already on our system. Let’s get compiling…

Compile PCRE

We need to compile PCRE into a local directory (not system-wide) so the PHP compiler has access to the headers it will need. This is pretty easy, just run the following:

cd /src/pcre
tar -zxvf pcre-7.7.tar.gz
cd pcre-7.7
./configure --disable-shared --enable-static
make && make install DESTDIR=/src/pcre/pcre-local

That’s it! Now we can start playing around with PHP

Compile PHP

Basically, what we’re going to be doing here is recompiling PHP 5.3 with the same config parameters as it was originally built with, but changing the things we need for GD and PCRE. It’s important that you follow all the steps outlined here, or you’ll get some weird compile errors. Also, if you’re a bit uncomfortable about recompiling, remember that you’re not going to mess anything up until you actually run the “make install” command. So, if the compile fails for any reason, your current PHP install isn’t going to get messed up in any way.

So, let’s get started:

cd /src/php
bunzip2 php-5.3.0.tar.bz2 && tar -xvf php-5.3.0.tar
cd php-5.3.0

Now, we’ll need to edit one file to fix a compile error we’ll run into. Open /src/php/php-5.3.0/ext/iconv/iconv.c in your editor of choice, and head to line 186. We need to change the line from:
“#define iconv libiconv”
to
“#define iconv iconv”

Once you’ve done that, we’re good to go. Assuming you’re still in /src/php/php-5.3.0:

MACOSX_DEPLOYMENT_TARGET=10.6
CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch x86_64 -g -Os -pipe"
LDFLAGS="-arch x86_64 -bind_at_load"
export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
./configure --prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--disable-dependency-tracking \
--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-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/X11R6 \
--with-freetype-dir=/usr/X11R6 \
--with-xpm-dir=/usr/X11R6 \
--with-ldap=/usr \
--with-ldap-sasl=/usr \
--enable-mbstring \
--enable-mbregex \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/tmp/mysql.sock \
--with-iodbc=/usr \
--enable-shmop \
--with-snmp=/usr \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-xmlrpc \
--with-iconv-dir=/usr \
--with-xsl=/usr \
--with-pcre-regex=/src/pcre/pcre-local/usr/local

If everything completed without error, you’re ready to compile (again, if this fails, nothing is messed up with your current PHP installation):

export EXTRA_CFLAGS="-lresolv"
make

This will take a few moments, so go grab a coffee or something ;) If this step completed properly (i.e you get some message about “don’t forget to run make test”), you’re ready to finish up. One thing I like to do is back up my current php.ini file, but if you haven’t tweaked it (or created it for that matter), you don’t need to do this:

sudo cp /etc/php.ini /etc/php.ini.bak

Now, you can install our fresh PHP build:

sudo make install

That’s it! Now, you can copy your old php.ini file back, and restart apache:

sudo cp /etc/php.ini.bak /etc/php.ini
sudo apachectl restart

If you set up a phpinfo() somewhere in your doc root, you should now see something like the following in the GD section of it:
PHP 5.3 GD with Freetype

Enjoy ;)

Other's Thoughts   (55 so far...)


  • bugi
    Oct 6 '09 at 11:26 pm

    Thanks Ian,
    just what I needed. :)

    I had to install libjpeg before your solution did work

    cd /src
    mkdir libjpeg
    cd libjpeg
    curl http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-53/libjpeg/jpegsrc.v6b.tar.gz -O
    tar xzf jpegsrc.v6b.tar.gz
    cd jpeg-6b/
    ln -s `which glibtool` ./libtool
    ./configure –enable-shared && make && sudo make install

    (last two lines google’d from http://tomster.org/blog/installing-libjpeg-on-os-x/?searchterm=cd)


  • hafiz
    Oct 7 '09 at 5:42 am

    If anyone get any error like below (libiconv) while compiling

    ====================
    Undefined symbols:
    “_libiconv_open”, referenced from:
    _do_convert in gdkanji.o
    __php_iconv_strlen in iconv.o
    _php_iconv_string in iconv.o
    __php_iconv_strpos in iconv.o
    _zif_iconv_substr in iconv.o
    _zif_iconv_substr in iconv.o
    __php_iconv_mime_decode in iconv.o
    __php_iconv_mime_decode in iconv.o
    _zif_iconv_mime_encode in iconv.o
    _zif_iconv_mime_encode in iconv.o
    _php_iconv_stream_filter_factory_create in iconv.o
    _convert in encodings.o
    “_res_9_dn_expand”, referenced from:
    ==========================

    1. do check the libiconv inside /usr/lib, or /usr/local/lib,
    you may have more libiconv or old libiconv libraries installed.

    2. Check you search path.

    3. Download the latest libiconv from their website.


  • Ian
    Oct 7 '09 at 8:17 am

    @hafiz,

    You can get those errors if you don’t edit the libiconv.c file per my instructions as well… Seems like your solution might be the better route, but the little edit does the trick as well :)


  • Ryan Parman
    Oct 7 '09 at 11:11 am

    Personally, I prefer to just use MacPorts. It makes for a much cleaner install. http://j.mp/11pULu


  • ricbax
    Oct 15 '09 at 5:20 am

    @hafiz
    I took 1,2, and 3 into consideration and I get the following which is slightly different from what you posted:
    ===============================
    Undefined symbols:
    “_iconv”, referenced from:
    __php_iconv_appendl in iconv.o
    __php_iconv_appendl in iconv.o
    _php_iconv_string in iconv.o
    _php_iconv_string in iconv.o
    __php_iconv_strlen in iconv.o
    __php_iconv_substr in iconv.o
    __php_iconv_strpos in iconv.o
    __php_iconv_mime_encode in iconv.o
    __php_iconv_mime_encode in iconv.o
    __php_iconv_mime_encode in iconv.o
    __php_iconv_mime_encode in iconv.o
    __php_iconv_mime_encode in iconv.o
    __php_iconv_mime_encode in iconv.o
    _php_iconv_stream_filter_append_bucket in iconv.o
    _php_iconv_stream_filter_append_bucket in iconv.o
    _php_iconv_stream_filter_append_bucket in iconv.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [libs/libphp5.bundle] Error 1
    ===============================


  • Simon Birve
    Oct 16 '09 at 6:48 am

    Thanks Ian for this article. It saved me.
    I had to install libjpeg7 before compiling php despite the change in my inconv.c file.
    This is what i did.

    cd /src
    mkdir libjpeg
    cd libjpeg
    Downloaded jpegsrc.v7.tar.gz from Freashmeat (http://freshmeat.net/projects/libjpeg/) to /libjpeg
    cd jpeg-7
    tar xzf jpegsrc.v6b.tar.gz
    cp /usr/share/libtool/config/config.sub .
    cp /usr/share/libtool/config/config.guess .
    -
    export MACOSX_DEPLOYMENT_TARGET=10.6
    CFLAGS=”-arch x86_64″ \
    CXXFLAGS=”-arch x86_64″ \
    LDFLAGS=”-arch x86_64″ \
    ./configure –enable-shared
    -
    make
    sudo make install

    (the flags from http://diymacserver.com/installing-php/adding-the-gd-module-to-php-on-snow-leopard/)
    I the run command from “Compile PHP” above.

    Worked like a charm and i now have GD as you shown above.
    /s


  • Simon Birve
    Oct 16 '09 at 6:59 am

    Sorry some typo above

    cd libjpeg
    Downloaded jpegsrc.v7.tar.gz from Freashmeat (http://freshmeat.net/projects/libjpeg/) to /libjpeg
    tar xzf jpegsrc.v7.tar.gz
    ….
    /S


  • ivanjovanovic
    Oct 22 '09 at 10:38 am

    I had to build the libjpeg as well before the building of php.
    As I read in the PHP manual, pcre is bundled now and you can just skip the last line of the configuration parameters and building pcre also.


  • Jose Antonio Andujar
    Oct 29 '09 at 12:30 am

    Hello,
    I had some problems. I need to compile the jpeg-6b like bugi, modify some header for type int64 and uint64 and compile with this. (jpeg and php)
    MACOSX_DEPLOYMENT_TARGET=10.6
    CFLAGS=”-arch x86_64 -arch i386 -g -Os -pipe -no-cpp-precomp”
    CCFLAGS=”-arch x86_64 -arch -g -Os -pipe”i386
    CCFLAGS=”-arch x86_64 -arch i386 -g -Os -pipe”
    CXXFLAGS=”-arch x86_64 -arch i386 -g -Os -pipe”
    LDFLAGS=”-arch x86_64 -arch i386 -bind_at_load”
    export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET

    I’m buildin on a mac mini intel core


  • lunix
    Nov 2 '09 at 4:53 am

    Great article, and thanks simon for the tip :)


  • Eric Newman
    Nov 2 '09 at 5:27 am

    Beware of funny quote signs, and missing, or malformed dash characters above. The gist of this is correct, but don’t just copy and paste it.


  • David Nash
    Nov 19 '09 at 3:27 am

    Excellent ‘howto’ – Thanks for the help


  • Jeff Barlow
    Nov 25 '09 at 4:22 pm

    If you get the following errors:

    php5.so
    ld: warning: in /usr/local/lib/libpng.dylib, file is not of required architecture
    Undefined symbols:
    “_png_set_PLTE”, referenced from:
    _php_gd_gdImagePngCtxEx in gd_png.o
    “_png_set_packing”, referenced from:
    _php_gd_gdImagePngCtxEx in gd_png.o
    _php_gd_gdImageCreateFromPngCtx in gd_png.o
    “_png_read_update_info”, referenced from:
    _php_gd_gdImageCreateFromPngCtx in gd_png.o
    “_png_get_tRNS”, referenced from:
    _php_gd_gdImageCreateFromPngCtx in gd_png.o
    _php_gd_gdImageCreateFromPngCtx in gd_png.o
    _php_gd_gdImageCreateFromPngCtx in gd_png.o

    “_png_get_PLTE”, referenced from:
    _php_gd_gdImageCreateFromPngCtx in gd_png.o
    “_png_create_info_struct”, referenced from:
    _php_gd_gdImagePngCtxEx in gd_png.o
    _php_gd_gdImageCreateFromPngCtx in gd_png.o
    “_png_set_IHDR”, referenced from:
    _php_gd_gdImagePngCtxEx in gd_png.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [libs/libphp5.bundle] Error 1

    You have to recompile libpng. I did:
    cd ..
    mkdir libpng
    cd libpng
    curl http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-53/libpng/libpng-1.2.37.tar.bz2 -O
    tar xzf libpng-1.2.37.tar.bz2
    cd libpng-1.2.37
    ln -s `which glibtool` ./libtool
    ./configure -enable-shared && make && sudo make install

    and things worked like a charm! Thanks to all for your help!


  • Kurt Collins
    Jan 10 '10 at 4:19 pm

    Thank you so much for this. :-)


  • Galen Sprague
    Jan 13 '10 at 1:00 pm

    This is great thank you very much! I also had to install libjpeg with the same flags as the php install to get it to compile. Working great now!!! Thanks again, this is awesome!!!!


  • Randy Hobart
    Jan 17 '10 at 6:45 am

    Thank you for your time in writing these instructions.
    I was successful in the recompile and works great.
    Recompiled on the MacBook I just purchase 1 week ago.

    Had to compile the jpegsrc.v7.tar.gz as above.
    —–
    One big change is that the below file is no longer there.
    curl ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz -O
    It is now ——
    curl ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz -O
    —–
    It took about 4 times to get it right.
    I found out you can copy the configure settings straight from you black box above.
    This saved alot of time.
    ——
    Thanks again, my php is running great now.
    And thanks for the comments given by others, could not have done it without all this help.


  • Mike Kormendy
    Jan 23 '10 at 4:13 am

    For myself as well, I had to install libjpeg7 before compiling PHP.
    In some cases, please be aware of your compiling for 64bit or 32bit as discussed in this post:
    http://diymacserver.com/installing-php/adding-the-gd-module-to-php-on-snow-leopard/

    1. download source files (with corrected pcre ver 7.9 & php)
    2. compile your PCRE
    3. download source files (libjpeg7)
    4. compile libjpeg7
    5. compile php

    Here are Simon Birve’s steps, CORRECTED, in one go (for 64bit):

    cd /src
    mkdir libjpeg
    cd libjpeg
    curl http://www.ijg.org/files/jpegsrc.v7.tar.gz -O
    tar xzf jpegsrc.v7.tar.gz
    cd jpeg-7
    cp /usr/share/libtool/config/config.sub .
    cp /usr/share/libtool/config/config.guess .
    export MACOSX_DEPLOYMENT_TARGET=10.6 \
    CFLAGS=”-arch x86_64″ \
    CXXFLAGS=”-arch x86_64″ \
    LDFLAGS=”-arch x86_64″
    ./configure –enable-shared
    make
    sudo make install


  • Mike Kormendy
    Jan 23 '10 at 4:40 am

    Also wanted to mention something about plugging in mcrypt (useful for latest version phpmyadmin) for php as discussed here:

    http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/

    Recompiling PHP will NOT affect a previous mcrypt plug-in installation. :-)

    I am running a 64bit Xserve with Snow Leopard 10.6.2, and the above process with pcre7.9 and libjpeg7 worked flawlessly for me and maintains mcrypt.

    Thanks to all who contributed.


  • Dae
    Jan 23 '10 at 6:31 am

    The link to PCRE 7.7 didn’t work, so I took the link to PCRE 7.9 from the comment above, but make failed with the following:
    =======
    Dae-MacPro:pcre-7.9 Dae$ make
    make all-am
    /bin/sh ./libtool –tag=CC –mode=compile gcc -DHAVE_CONFIG_H -I. -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -MT pcre_compile.lo -MD -MP -MF .deps/pcre_compile.Tpo -c -o pcre_compile.lo pcre_compile.c
    gcc -DHAVE_CONFIG_H -I. -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp -MT pcre_compile.lo -MD -MP -MF .deps/pcre_compile.Tpo -c pcre_compile.c -o pcre_compile.o
    gcc-4.2: -E, -S, -save-temps and -M options are not allowed with multiple -arch flags
    make[1]: *** [pcre_compile.lo] Error 1
    make: *** [all] Error 2
    =======

    I didn’t fix the problem: instead I took PCRE 7.7 from here:
    http://downloads.sourceforge.net/project/pcre/pcre/7.7/pcre-7.7.tar.gz

    Make worked like a charm with the older version.


  • Ron
    Jan 31 '10 at 2:13 pm

    Does anyone know if this works for OS X Snow Leopard Server as well?


  • RS
    Feb 1 '10 at 10:22 pm

    Anyone try this with PHP 5.3.1? I’m going to give it a shot tomorrow, but thought I’d ask before potentially wasting an afternoon. =P


  • RS
    Feb 3 '10 at 7:59 pm

    So, this does work with PHP 5.3.1 directly downloaded from php.net. I did have to download pcre8.01, as well as jpeg7. But, it’s working with 10.6.2 server.


  • Frank
    Feb 4 '10 at 6:23 am

    Hi there,

    I have a question that I have no idea how to solve. I have Snow Leopard installed on my MAC with PHP enabled (using text wrangler and modifying the etc/apache2/httpd.conf file). I would like to know how do I enable the GD part of it? I found this really awesome PHP slideshow script that I want to use, but it won’t work properly since I do not have the GD part of PHP enabled. If anyone can help me or tell me how to do this would be greatly appreciated. Thanks :-)


  • Pope7
    Mar 3 '10 at 3:27 pm

    I’m trying to compile this on Snow Leopard Server, and when compiling PCRE I get the following:

    hecking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for a thread-safe mkdir -p… ./install-sh -c -d
    checking for gawk… no
    checking for mawk… no
    checking for nawk… no
    checking for awk… awk
    checking whether make sets $(MAKE)… no
    checking for gcc… no
    checking for cc… no
    checking for cl.exe… no
    configure: error: no acceptable C compiler found in $PATH

    But I haven’t found a solution yet to that last error: “no acceptable C compiler fond in $PATH” – any suggestions?


  • Ryan H
    Mar 4 '10 at 5:27 am

    I recently had to add mcrypt support in order to use phpMyAdmin and followed this tutorial [http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/] to do so in which the mcrypt.so module was built separately so that the stock PHP installation did not have to be messed around with.

    After successfully following this article for GD, I though, hey why can’t I do the same for gd.so? Well, it’s too late for me now, but perhaps someone else can benefit.

    First, you’ll need to install the jpeg library as people have noted above. It should be noted that I tried pointing to a MacPorts installation of it as well as a “local” installation and neither worked. One failed the build process while another failed to even configure. For some reason it’s got to be in /usr/local, so it would seem.

    (I’m going to try to use tags so that the command lines do not get messed up, but I don’t know what will happen)

    To build just the module:

    cd /src/php/php-5.3.0/ext/gd
    /usr/bin/phpize

    MACOSX_DEPLOYMENT_TARGET=10.6
    CFLAGS=”-arch x86_64 -g -Os -pipe -no-cpp-precomp”
    CCFLAGS=”-arch x86_64 -g -Os -pipe”
    CXXFLAGS=”-arch x86_64 -g -Os -pipe”
    LDFLAGS=”-arch x86_64 -bind_at_load”
    export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
    ./configure \
    –with-zlib-dir=/usr \
    –with-jpeg-dir=/usr/local/lib \
    –with-png-dir=/usr/X11R6 \
    –with-freetype-dir=/usr/X11R6 \
    –with-xpm-dir=/usr/X11R6

    If all goes well, make and sudo make install. Then, in your php.ini file, go to the Dynamic Extensions section and add:

    extension=gd.so

    I have not tested this because I have already installed the modified version of PHP with the GD support built-in, but this might save someone from doing that so that if and when Apple updates PHP via a software update, you won’t have to go through all this again.


  • Ryan H
    Mar 4 '10 at 5:29 am

    Ok, the “pre” tag didn’t work, so make sure you use double dashes for each “with” line.


  • Spyro
    Mar 5 '10 at 1:13 pm

    Hello,
    what if I want to install PHP *without* gd support and add gd as dynamic extension ? (And if I don’t have a 64bit machine by the way, my core duo is a bit old)


  • leggo-my-eggo
    Mar 8 '10 at 6:49 am

    Hi, this seems to be working well, except, if I run apachectl -t, I get the following error:

    httpd: Syntax error on line 155 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_auth_user_host_apple.so into server: dlopen(/usr/libexec/apache2/mod_auth_user_host_apple.so, 10): Symbol not found: __cg_jpeg_resync_to_restart\n Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib\n Expected in: /usr/lib/libJPEG.dylib\n in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib

    Dos anyone know how to fix this, or what I did wrong?


  • ozboss
    Mar 15 '10 at 10:35 am

    Thank you! Great, this is what i looked for!

    Worked for me with pcre 7.7 from
    http://downloads.sourceforge.net/project/pcre/pcre/7.7/pcre-7.7.tar.gz

    I also had to install libjpeg7
    http://www.ijg.org/files/jpegsrc.v7.tar.gz
    Be aware of right quotes in terminal, if you have something like
    -bash: export: `x86_64″’: not a valid identifier
    It has to be

    export MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=”-arch x86_64″ CXXFLAGS=”-arch x86_64″ LDFLAGS=”-arch x86_64″

    before

    ./configure -enable-shared && make && sudo make install

    That’s just for those guys of you using copy&paste to much ;-)


  • pk
    Mar 15 '10 at 8:21 pm

    THANK YOU THANK YOU THANK YOU!!! People like you make the web a great place! I really needed to get Freetype running and thanks to you (and everyone who posted additions) it’s done. Fantastic. Next time you’re in Sydney, the beers are on me.


  • Michael Mahoney
    Apr 7 '10 at 12:17 pm

    Hi, when I follow these directions I get the following error:

    httpd: Syntax error on line 155 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_auth_user_host_apple.so into server: dlopen(/usr/libexec/apache2/mod_auth_user_host_apple.so, 10): Symbol not found: __cg_jpeg_resync_to_restart\n Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib\n Expected in: /usr/lib/libJPEG.dylib\n in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib

    Anyone understand why?


  • jmcbade
    Apr 8 '10 at 5:50 am

    I just want to add my “Thank You” for this wonderful share. I did need to use Simon’s tip to make it all work so thank you Simon also.

    Now running PHP 5.3.2, pcre8 and libjpeg 8 Cool!

    Awesome guys. Made it work for me :)


  • jmcbade
    Apr 17 '10 at 5:23 am

    Hmmm… After doing these steps, I can no longer get xDebug working.

    I have the correct xdebug.so file in: usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so

    I have the lines in the /etc/php.ini file:
    [xdebug]
    zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
    xdebug.remote_enable=on
    xdebug.remote_handler=dbgp
    xdebug.remote_host=localhost
    xdebug.remote_port=9000

    It worked before this. I’m using xdebug with Netbeans 6.8

    I run phpinfo() and xdebug is no longer running.

    Thank in advance for assistance.


  • jmcbade
    Apr 17 '10 at 6:12 am

    Ah!!! This was a really elusive one. I hope this helps someone else.

    I have a character that was incorrect in my php.ini file. I found it when I did a “which php” from a command line.


  • Pim
    Apr 28 '10 at 7:02 am

    Please keep in mind that this article assumes that you have X11 installed. Find it in Optional Installs on your Snow Leopard install DVD and install it first.


  • Mike Kormendy
    May 9 '10 at 10:32 pm

    Okay all, I have an update for those with the following system:

    OS X Server 10.6.3
    PHP 5.3.1
    PCRE8.02
    LIBJPEG8a

    I did not have any hiccups with my install from the above steps, however make sure:
    - that you are compiling for the right architecture
    - that you do not copy and paste from this page into your terminal shell

    The double quotes have been converted in the comments section on this site and cause problems with copy and paste.

    @Dae: did you run as sudo su? that might fix the problem
    @Ron: this has worked for my SL Server 10.6.3
    @RS: alternatively you can download from Apple’s repository: http://www.opensource.apple.com/


  • MikeT
    Jun 1 '10 at 3:30 am

    Thank you for posting this, and also thanks to those who posted updates above.

    These instructions seem to work well with:
    libjpeg v8a
    PHP 5.3.2
    … I chose to stick with pcre-7.7

    I was on Snow Leopard 10.6.3, and have compiled this way on my two dev machines.

    I’ve been able to further install freetype-dependent projects like pChart and use them properly.

    Thanks again!


  • Ray
    Jun 10 '10 at 7:55 pm

    Almost there! After export EXTRA_CFLAGS=”-lresolv” and make I get the error “make: *** No targets specified and no makefile found. Stop.” What’s wrong?


  • M Smith
    Jul 23 '10 at 12:16 pm

    Thanks a lot! Got me going with LimeSurvey problems on a OS X Snow Leopard Server,

    kudos


  • Josuah
    Jul 29 '10 at 11:46 pm

    Note that you need to have X11 installed – else you will get missing xpm, libpng and other errors. If you do not want to install it but instead compile each missing packages then you will need to adjust the paths in the php configure to reflect that.


  • sram
    Aug 6 '10 at 10:05 am

    I am having issues. I have managed to successfully compile pcre and libjpeg.
    When I try to compile php using the text in the black box above, I receive dozens of errors similar to:

    i686-apple-darwin10-gcc-4.2.1: -lresolv: linker input file unused because linking not done

    /src/php/php-5.3.0/ext/sqlite3/libsqlite/sqlite3.c:46113: warning: cast from pointer to integer of different size

    and others.

    This is all under 10.6.3 server. I have updated to 10.6.4 but it’s still the same.

    During the configure stage I received an error telling me that –disable-dependency-tracking was an unknown option. Apart from that, configure went well.

    totally lost. cheers


  • Tony Björkholm
    Aug 16 '10 at 2:47 pm

    Thanks a lot!

    This was exactly what i was looking for. And it worked.
    Things i got stuck on was that i had to download and install libjpg and libpng to get the command “./configure –prefix=/usr \”
    to work. And the link ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz -O returned a 550 error so i got the files from another source.


  • shofikh
    Aug 21 '10 at 9:11 am

    Thanks For this great article.
    This does work with
    SL 10.6.4
    PHP 5.3.3
    PCRE8.10
    LIBJPEG8b


  • ROn
    Aug 30 '10 at 3:55 pm

    Amazing how every Snow Leopard update breaks this… ugh. But just kept all my files in the same place and installed again and I am back up. :-)


  • iBeb
    Sep 4 '10 at 12:31 am

    My question may be a bit stupid, but I take the risk.
    After installing everything, can I delete the /src folder?
    If not, is there a way to move files somewhere else?


  • Jen
    Oct 5 '10 at 10:48 am

    Thank you so much! I needed to get freetype working for pChart and this solved the problem for me. I did find that I had to create the directory /usr/local/man/man1/cjpeg.1 for the libjpeg install to work though.


  • Attila F
    Dec 6 '10 at 12:59 am

    configure: error: Problem with libjpeg.(a|so). Please check config.log for more information.

    Anybody had the above problem during php configure?


  • Jared Henderson
    Dec 8 '10 at 7:35 am

    Finally got this working on 3 different Macs with the help of this tutorial and a bunch of digging. A few lessons learned:

    a current, working replacement for the PCRE download line is:

    curl http://voxel.dl.sourceforge.net/project/pcre/pcre/7.7/pcre-7.7.tar.gz -O

    Also, if you get a “configure: error: no acceptable C compiler” on a Mac that has been UPGRADED to Snow Leopard, RE-install xcode from the upgrade DVD (under “optional installs”)

    I also found I had to install LIBJPEG for all three Macs. And had to search out some up-to-date download urls, which are included in linked file below.

    I had a couple of other weird problems that turned out to be copy-paste issues (as noted above), some involving curly-quotes, but also one with a hyphen that stumped me for a while. I created a text document with all the terminal commands that can be mostly copy pasted (except swapping out your own username, and you still need to do the bit about changing the line in “iconv.c”), and I’ve linked to it below.

    The link contains the terminal commands that I used to to this successfully on three different macs, including up-to-date download sources:

    http://blog.rachelhendersonphotography.com/wp-content/uploads/2010/12/recompile-php5-3-with-freetype.sh

    I couldn’t have done it without this post. Thanks so much!


  • Adam
    Dec 11 '10 at 9:28 am

    Jared Henderson, thank you for combining all of the updated information into that file. Saved a lot of time and worked great! Thank you.


  • troot
    Dec 22 '10 at 11:20 am

    Just thought I’d share what I had to do on my MacBook Pro to get this to configure (based on Jareds shell script). I don’t know if it’s right, but I had to change the –with-freetype-dir parameter for the php ./configure command to /usr/X11/ and prepend the command with LIBS=-lresolv. I based it on this article here: http://www.issociate.de/board/post/499984/cannot_compile_PHP_5.2.11_on_Mac_OS_X_10.6.1.html

    Otherwise I kept getting an error. Seems to be working so thanks.


  • Tim
    Jan 11 '11 at 1:47 am

    Worked perfectly! Thanks :D


  • PK
    Mar 4 '11 at 4:00 pm

    This site has saved me so much pain – thanks sincerely Ian. And Jared Henderson – I love you man!

  • Share Your Thoughts...

    Some HTML is ok. If this is your first comment on my site, it will be reviewed before being posted publicly. Your comment may be edited or marked as spam if it appears intended for SEO purposes.