Configure GD with PHP on OSX 10.6.8

GD and PHP

I Installed GD, depency jpeglibtool, and recompiled php using these instructions do not pay attention to the 64bit g5 code below.

Adding GD support to builtin php5 on OSX Leopard server

Backup your system Install (and update) the latest XCode (I’ve got version 3) Install X11 client stuff from your server install DVDinstall X11 SDK stuff from your server install DVD Ensure you have server 10.5.8 (latest update as of Feb.04.2011) Make sure you have not tried to install GD using another method. We need a fresh 10.5.8 install (as far as homebrew/local installs) BACKUP Please note that this will add GD support to php. This is NOT the same as compiling the GD graphics library (libgd).

Okay, so now that we have all the requirements, you need to get a command line window opened and get a root shell (sudo -i). The rest of this document assumes you‚ Are typing the commands in a root shell.

There is one dependency that we need to clear before we actually get down and dirty and that is libjpeg (known as jpegsrc). Follow the instructions below to get this installed:

mkdir /SourceCache cd /SourceCache curl -O This is the latest version as of this writing (Feb.04.2011).

tar -zxvlf jpegsrc.v8c.tar.gz cd jpeg-8c/ ./configure make make testmake -n install The last command will simulate the installation process. Make sure the stuff is getting installed in /usr/local/lib

make install At this point you should have a working installation of libjpeg. Now we double check our php version.

server:jpeg-8c root# php -v PHP 5.2.14 (cli) (built: Oct 6 2010 16:57:10) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies Notice in the output that I have php 5.2.14 installed on the machine (again the latest update as of Feb.04.2011). Apple does not provide source code for this exact version of PHP. On top of that The numbering scheme that they use is weird. On my machine it is ‚ Apache_mod_php-44.6‚ you can find yours using the following:

server:jpeg-8c root# php -i |more phpinfo() PHP Version => 5.2.14

System => Darwin 9.8.0 Darwin Kernel Version 9.8.0: Wed Ju l 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 Build Date => Oct 6 2010 16:55:34 Configure Command => ‘/SourceCache/apache_mod_php/apache_mod_php-44.6/php/confi gure’ ‘–prefix=/usr’ ‘–mandir=/usr/share/man’ ‘–infodir=/usr/share/info’ ‘– disable-dependency-tracking’ ‘–with-apxs2=/usr/sbin/apxs’ ‘–with-ldap=/usr’ ‘- -with-kerberos=/usr’ ‘–enable-cli’ ‘–with-zlib-dir=/usr’ ‘–enable-trans-sid’ ‘–with-xml’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-mbstring’ ‘–enable-mbrege x’ ‘–enable-dbx’ ‘–enable-sockets’ ‘–with-iodbc=/usr’ ‘–with-curl=/usr’ ‘–w ith-config-file-path=/etc’ ‘–sysconfdir=/private/etc’ ‘–with-mysql-sock=/var/m ysql’ ‘–with-mysqli=/usr/bin/mysql_config’ ‘–with-mysql=/usr’ ‘–with-openssl’ ‘–with-xmlrpc’ ‘–with-xsl=/usr’ ‘–without-pear’ The thing you‚ Are looking for (Apache_mod_php-44.6) is under Configure Command. If you go to the following URL ( in your browser (safari, firefox) you’ll soon discover these weird directory names with numbers that don’t match the php versions. Again, as of this writing (Feb.04.2011), I can‚Äôt find apache_mod_php-44.6 folder in the listing so I grabbed the nearest numbers apache_mod_php-44.2 which is php 5.2.8 is close enough. It seems to work. Follow the steps below to get the file and compile the GD portion of it. Remember we Are not recompiling the entire php, just the GD plugin portion.

UPDATE: You CAN install the exact version of your PHP’s GD extension. Instead of grabbing the file from Apple, figure out the version of your PHP using and grab the appropriate file from instead. I just recompiled the GD portion of PHP 5.2.14, since I wanted a perfect match between my php engine and the extension. The instructions below (except curl which needs to be modified) work.

cd /SourceCache curl -O tar xjvf php-5.2.8.tar.bz2 cd /SourceCache/php-5.2.8/ext/gd phpize ./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 makemake test make -n install The last command will simulate the installation process. Make sure the stuff is getting installed in /usr/lib/php/extensions/no-debug-non-zts-20060613

make install Now we need to modify our php.ini file and tell the php5 engine of the availability of this new module. To do this you need to copy php.ini.default to php.ini (in /etc directory). For details of why have a look at this article.

cd /etc cp php.ini.default php.ini Edit the newly created/copied php.ini using your favourite editor. Add the following line to the appropriate location (read the comments in the file to find the location): Still in the same file find the variable “extension_dir” and change it’s value to “/usr/lib/php/extensions/no-debug-non-zts-20060613″ path instead of “./”. Save the php.ini and use the following command to see if GD extensions are available:

server:etc root# php -i |grep GD GD Support => enabled GD Version => bundled (2.0.34 compatible) Done. Restart Apache service from the server manager (just for the sake of completeness).

Leave a Reply

Your email address will not be published.