2012-03-05

Compile PHP with bundled gd

For security reason, PHP on Debian and ubuntu does not include bundled function from PHP package such like imageantialias and imagerotation. To support these you have to compile PHP by yourself. Here is the process:
1. install build tools:
$ apt-get install build-essential debhelper fakeroot
2. Download sources 
$ cd /usr/src
$ apt-get source php5 
3. Install dependent packages
$ apt-get build-dep php5
4. Change setting:
$ cd php5-xxx/
$ cd debian/
$ sudo vim rules 
find line:
--with-gd=shared,/usr --enable-gd-native-ttf \
replace it with:
--with-gd=shared --enable-gd-native-ttf \ 

Edit file /usr/src/phpXXX/debian/setup-mysql.sh

# Add "--user=root" to:
# $mysqld > $datadir/run.log 2>&1 &
$mysqld --user=root > $datadir/run.log 2>&1 &

After this, run this command to start compiling in the php source folder:
$ dpkg-buildpackage -rfakeroot