GD library compile from source: Debian Lenny

Written by Peter Davies on .

It appears that various useulf functions, that my php applications need require you to compile the GD library from source. The steps below outline this procedure:

cd /usr/src
ls -al

apt-get source php5-gd
apt-get build-dep php5-gd
cd php5-5.2.6.dfsg.1/
nano debian/rules

cd php5-5.2.6.dfsg.1/
nano debian/rules

edit the line where it says:

gd=shared,/usr --enable-gd-native-ttf
change to
gd=shared --enable-gd-native-ttf

Then you need to compile the code and replace your existing module with the newly created one:

dpkg-buildpackage
updatedb
locate gd.so
mv /usr/lib/php5/20060613/gd.so /usr/lib/php5/20060613/gd.so~pkd
cp /usr/src/php5-5.2.6.dfsg.1/apache2-build/modules/gd.so /usr/lib/php5/20060613/

It's then usually advisable to restart apache so that you can see the changes.

References:
http://www.howtoforge.com/recompiling-php5-with-bundled-support-for-gd-on-ubuntu