Installing GD 1.3 for PHP on Linux
by Nathan Wallace (Oct 25, 1999)
Introduction
This document describes the installation of the GD graphics library on Linux for use with PHP. We are using an old version of this library since newer versions do not allow the generation of gif files due to patent problems.
I've assumed that you have Apache and PHP installed in /usr/local/etc/php as per my instructions.
Getting GD
- You need to be working as root to install gd.
su root
- I like to keep a copy of my downloaded programs in
/usr/local/download
So create this directory if you don't already have one.
- You can download GD from here.
- Save the file as:
/usr/local/download/gd1.3.tar.gz
using these commands:
cd /usr/local/download
ftp ftp.example.com
cd pub
cd gd
bin
get gd1.3.tar.gz
bye
Installing GD
- First we have to unpack the download. We are going to install it into /usr/local/gd1.3. I've used a pretty cryptic tar command below to do it all in one hit.
cd /usr/local/download
tar xzf gd1.3.tar.gz -C ..
- Let's make the GD stuff easy to find:
cd ..
ln -s gd1.3 gd
- Now we need to compile everything:
cd gd
make
Checking it Worked
- You can run the gddemo program to check that the installation is working:
./gddemo
- This demo program generates a gif file:
demoout.gif
which you can look at in your browser by downloading it from your server or calling up the file directory.
Adding GD Support to PHP
- Jump into the php installation directory:
cd ../etc/php
- We need to configure PHP to use GD. You should just use the configure command that you used last time and add --with-gd=/usr/local/gd to it. If you followed my instructions for installing PHP with MySQL then your configure command will look like this:
./configure --with-apache=../httpd --with-mysql=/usr/local/mysql --enable-track-vars --with-gd=/usr/local/gd
- Make the new PHP library:
make
make install
- Now we have to remake apache to use the new PHP:
cd ../httpd
make
make install