step-by-step instructions for compiling PHP

andrew morgan morgan@orst.edu
Wed, 7 Feb 2001 08:37:54 -0800 (PST)


With all the recent problems setting up PHP for use with Horde/IMP, I
thought I'd write down the exact steps which I use to compile Apache and
PHP in preparation for running IMP.

You'll need three source packages, Apache, UW-IMAP, and PHP.  Here are the
versions I am using:

apache_1.3.14.tar.gz (from www.apache.org)
imap-2000c.tar.gz (from www.washington.edu/imap)
php-4.0.4pl1.tar.gz (from www.php.net)

I copy these files to a directory /private/src where I do my compilation:

mkdir /private/src
cp apache_1.3.14.tar.gz imap-2000c.tar.gz php-4.0.4pl1.tar.gz /private/src
cd /private/src

Extract the source from these files by running:

gunzip -c apache_1.3.14.tar.gz | tar xvf -
gunzip -c imap-2000c.tar.gz | tar xvf -
gunzip -c php-4.0.4pl1.tar.gz | tar xvf -

We will compile imap first.  Look in imap-2000c/Makefile for a list of
system codes to identify your operating system.  I use 'gso' for GCC on
Solaris.  You might use 'lnp' for Linux with PAM:

cd imap-2000c
make gso

That's it for imap.  You don't need to install it.  We are just trying to
build the c-client.a library, which you should now have in the
/private/src/imap-2000c/c-client directory.

Next we have to do a little prep work on the apache source by running the
configure script without any options.  This sets up some stuff that php
needs:

cd ../apache_1.3.14
./configure

Now we build php:

cd ../php-4.0.4pl1
./configure --with-imap=/private/src/imap-2000c/ \
--with-apache=/private/src/apache_1.3.14/ --prefix=/private/apache/php/ \
--with-config-file-path=/private/apache/conf/

This points php to the imap library we just compiled and the target apache
source directory.  I will be installing Apache in /private/apache.  I like
to put the php libraries in a subdirectory there, and I also like to put
the php.ini config file in with my apache config files rather than the
default directory, /usr/local/lib.  It is worth noting that MySQL support
comes with php in recent versions (maybe php4 in general?), so you don't
have to download and compile mysql or even specify it on the php configure
command line.

Next we build and install php:

make
make install

Now we need to go back and configure Apache to use php:

cd ../apache_1.3.14
./configure --prefix=/private/apache \
--activate-module=src/modules/php4/libphp4.a

This will install apache in /private/apache and activate the php4 module.
Then we build and install apache:

make
make install


And that is it.  From here on, you'll need to follow the Horde and IMP
installation instructions to configure php (use the
/private/apache/conf/php.ini file) and Horde/IMP.

Hope this helps people out there.  Compiling apache and php from source is
not at all difficult to do, and I would recommend it over using a package
any day.

	Andy