I got the latest version of PHP using the anonymous Git service,
but there's no configure script!

You have to have the GNU autoconf package installed so you can
generate the configure script from configure.in. Just run
./buildconf in the top-level directory after getting
the sources from the Git server. (Also, unless you run configure
with the --enable-maintainer-mode option, the
configure script will not automatically get rebuilt when the
configure.in file is updated, so you should make sure to do that
manually when you notice configure.in has changed. One symptom
of this is finding things like @VARIABLE@ in your Makefile after
configure or config.status is run.)

I'm having problems configuring PHP to work with Apache.
It says it can't find httpd.h, but it's right where I said it is!

You need to tell the configure/setup script the location of the
top-level of your Apache source tree. This means that
you want to specify --with-apache=/path/to/apache
and not--with-apache=/path/to/apache/src
.

While configuring PHP (./configure), you come across
an error similar to the following:

Be sure to read the installation
instructions carefully and note that you need both flex and bison
installed to compile PHP. Depending on your setup you will install
bison and flex from either source or a package, such as a RPM.

When I run make, it seems to run fine but then fails when it tries
to link the final application complaining that it can't find some files.

Some old versions of make that don't correctly put the compiled
versions of the files in the functions directory into that same
directory. Try running cp *.o functions and then
re-running make to see if that helps. If it does, you should really
upgrade to a recent version of GNU make.

When linking PHP, it complains about a number of undefined references.

Take a look at the link line and make sure that all of the appropriate
libraries are being included at the end. Common ones that you might have
missed are '-ldl' and any libraries required for any database support
you included.

Some people have also reported that they had to add '-ldl' immediately
following libphp4.a when linking with Apache.

Type make followed by make install
to build PHP and copy the necessary files to the Apache distribution tree.

Change directories into to your /<path>/apache-1.3/src
directory and edit the Configuration file.
Add to the file:
AddModule modules/php4/libphp4.a.

Type: ./configure followed by make.

You should now have a PHP-enabled httpd binary!

Note: You can also use the new Apache
./configure script. See the instructions in
the README.configure file which is part of
your Apache distribution. Also have a look at the INSTALL
file in the PHP distribution.

I have followed all the steps to install the Apache module version on
Unix, and my PHP scripts show up in my browser or I am being asked to
save the file.

This means that the PHP module is not getting invoked for some reason.
Three things to check before asking for further help:

Make sure that the httpd binary you are running is the actual
new httpd binary you just built. To do this, try running:
/path/to/binary/httpd -l
If you don't see mod_php4.c listed then
you are not running the right binary. Find and install the
correct binary.

Make sure you have added the correct Mime Type to one of your
Apache .conf files. It should be:
AddType application/x-httpd-php .php
Also make sure that this AddType line is not hidden away inside a
<Virtualhost> or <Directory> block which would
prevent it from applying to the location of your test script.

Finally, the default location of the Apache configuration files
changed between Apache 1.2 and Apache 1.3. You should check to
make sure that the configuration file you are adding the AddType
line to is actually being read. You can put an obvious syntax error
into your httpd.conf file or some other obvious change that will
tell you if the file is being read correctly.

It says to use: --activate-module=src/modules/php4/libphp4.a,
but that file doesn't exist, so I changed it to
--activate-module=src/modules/php4/libmodphp4.a and it
doesn't work!? What's going on?

Note that the libphp4.a file is not supposed to exist. The
apache process will create it!

When I try to build Apache with PHP as a static module using
--activate-module=src/modules/php4/libphp4.a
it tells me that my compiler is not ANSI compliant.

This is a misleading error message from Apache that has been fixed
in more recent versions.

When I try to build PHP using --with-apxs
I get strange error messages.

There are three things to check here. First, for some reason
when Apache builds the apxs Perl script, it sometimes ends up
getting built without the proper compiler and flags variables.
Find your apxs script (try the command which apxs),
it's sometimes found in /usr/local/apache/bin/apxs
or /usr/sbin/apxs.
Open it and check for lines similar to these:

Your system is broken. You need to fix your /usr/include files by
installing a glibc-devel package that matches your glibc. This has
absolutely nothing to do with PHP. To prove this to yourself, try this
simple test:

When compiling PHP with MySQL, configure runs fine but during
make I get an error similar to the following:
ext/mysql/libmysqlclient/my_tempnam.o(.text+0x46): In function
my_tempnam': /php4/ext/mysql/libmysqlclient/my_tempnam.c:103: the
use of tempnam' is dangerous, better use mkstemp',
what's wrong?

First, it's important to realize that this is a
Warning and not a fatal error. Because this is
often the last output seen during make,
it may seem like a fatal error but it's not. Of course, if
you set your compiler to die on Warnings, it will. Also
keep in mind that MySQL support is enabled by default.

Note:

As of PHP 4.3.2, you'll also see the following text after
the build (make) completes:

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

I want to upgrade my PHP. Where can I find the ./configure
line that was used to build my current PHP installation?

Either you look at config.nice file, in the source tree of your current PHP
installation or, if this is not available, you simply run a

<?php phpinfo(); ?>

script. On top of the output the ./configure line, that was used
to build this PHP installation is shown.

When building PHP with the GD library it either gives strange compile errors
or segfaults on execution.

Make sure your GD library and PHP are linked against the same depending
libraries (e.g. libpng).

When compiling PHP I seemingly get random errors, like it hangs.
I'm using Solaris if that matters.

Using non-GNU utilities while compiling PHP may cause problems. Be
sure to use GNU tools in order to be certain that compiling PHP will
work. For example, on Solaris, using either the SunOS BSD-compatible
or Solaris versions of sed will not work, but using
the GNU or Sun POSIX (xpg4) versions of sed will
work. Links: » GNU sed,
» GNU flex, and
» GNU bison.

If you update or reinstall any of the libraries used to compile in a different directory than they started out, you will need to make sure that you update the config.cache file (or re-generate it) so that configure will not look in the wrong place for the information.

On Mac OS X, for example, I updated my libxml using Fink. Fink placed the files in the /sw directory. However, php was still looking for important libxml files (such as xml2-config) in the old directory (/usr/bin/xml2-config). After updating config.cache with the new value of the xml2-config path, I was able to compile correctly.