I wanted to write this article for a long time but I never had the chance to do it. Today, I had to install the GD library on two different Ubuntu servers so I had to dig up my notes about this. After I fixed all the issues I thought now is the good time to write a quick howto.
Ubuntu Server 9.04 LTS
Some says that the steps for Ubuntu 8.04 does not work on Ubuntu 9.04, so you have to do it the hard way. Compiling PHP with GD library:
1) Install build tools, debian helpers and fakeroot
sudo apt-get install build-essential debhelper fakeroot
2) You need to download PHP source using apt. The source should go into /usr/src
cd /usr/src
apt-get source php5
3) Install all packages required to build PHP5
sudo apt-get build-dep php5
4) Now to add GD to the compile options you need to edit debian/rules file:
cd php5-5.2.6.dfsg.1 (if there is a newer version look for similar folder)
nano debian/rules
You need to remove reference to /usr so that bundled library is used:
a) Locate the line having "--with-gd=shared,/usr --enable-gd-native-ttf \"
b) Replace with "--with-gd=shared --enable-gd-native-ttf \"
5) You are no ready to compile PHP with GD support. This will take about 30-40 minutes.
dpkg-buildpackage -rfakeroot
6) Once the compiler is ready, install the new php5-gd package
cd ..
dpkg -i php5-gd_5.2.6.dfsg.1-3ubuntu4.2_i386.deb (if there is a newer version look for similar file)
7) The last step is, as usual to restart apache:
/etc/init.d/apache2 restart
Once Apache restarted, go back to Drupal's status page where the GD line should have a green checkmark.
Ubuntu Server 8.04 LTS
Installing PHP GD library on Ubuntu 8.04 is fairly simple providing you don't want to play around compiling PHP for 30-40 minutes.
1) This step is optional, you only have to do it if you already have a PHP GD library installed but it is not working or you get the following message on the Drupal Status page: "The installed version of PHP GD does not support image filtering (desaturate, blur, negate, etc.). [...]"
In this step you are going to remove the old GD library:
sudo apt-get --purge remove php5-gd
2) You need to add the following to line to the end of your apt sources file. The full path to the file: "/etc/apt/sources.list"
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
3) To be able to authenticate the packeges you need to download and add the GPG-signed key for dotdeb.org to your keychain:
gpg --keyserver keys.gnupg.net --recv-key 89DF5277
gpg -a --export 89DF5277 | sudo apt-key add -
4) To update the apt list run the following command:
sudo apt-get update
5) Now, you need to install the new PHP GD library from the location you just added to the source list. Before you run the following command, please note that any modification to your php.ini file will be lost so you might want to create a backup, just in case. When asked 'What would you like to do about php.ini?' select the 'MAINTAINER'S VERSION', press Y key, then press ENTER key.
sudo apt-get install php5-gd
6) Finally, you need to restart apache so all the changes can be applied.
sudo /etc/init.d/apache2 restart
Once Apache restarted, go back to Drupal's status page where the GD line should have a green checkmark.
Comments
Post new comment