Recompiling php5 with bundled gd lib support on debian etch

09:17PM Apr 19, 2009 in category Linux & Co by Alexander Pirsig

Today we're had a minor problem with the GD Lib. in PHP5-GD under Debian etch. The problem was that we've tried to you special functionality that is only available if you're using php own library. Instead of using the bundled library php provides the Debian and Ubuntu maintainers compile php5-gd package against the shared system library.

So what happens is that you're probably missing some extra functionality in your PHP gd calls for example there is no imagerotate() or imageantialias() functions. They are only available in the Bundled version that comes with PHP.

A typical error you get is this:


JpGraph Error The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.

But solving the problem thanks to debian is quite easy and only took some compile time. ;) To solve the problem I did the following steps:

Make sure your have you source package urls in apt sources.list defined simple check it by enter:


vi /etc/apt/sources.list
# A line like the following should appear
# source urls starting with deb-src for example:
deb-src http://ftp.de.debian.org/debian/ etch main contrib non-free

Next we're installing needed packages.


# Install build tools, debian helpers and fakeroot
apt-get install build-essential debhelper fakeroot
# source code should reside in /usr/src
cd /usr/src
# Download PHP source
apt-get source php5
# Install all packages required to build PHP5
apt-get build-dep php5

Now we're altering the build path for gdlib and make php to complile against the bundled gd lib version.


cd /usr/src/[PHP_VERSION]/debian # In my case php5-5.2.0
vi rules
# Next where changing gd lib compiler flag
# REPLACE: --with-gd=shared,/usr --enable-gd-native-ttf WITH: --with-gd=shared --enable-gd-native-ttf
# save and close
cd /usr/src/[PHP_VERSION]
dpkg-buildpackage -rfakeroot
# This takes a while
cd /usr/src
# Install new php5-gd lib package in my case:
dpkg -i php5-gd_5.2.0-8+etch13_amd64.deb
# Restart your apache or what every
/etc/init.d/apache2 restart
# Happy GD-ing :)

Kommentare[10] Tags: gd ubuntu imageantialias php building problem debian recompile gd2