The following notes are from a Unix perspective as this is the natural home for not only PHP and Apache but all things web.
Unix comes in many varying flavours so building software from source is often the preferred option, especially with open source wares.
The configuration concepts are however pretty much the same for each platform so see the PHP documentation for the bigger picture.
Regardless of the platform on which you are running there are a couple of configuration files that it is a good idea to have a look at and modify to suit your needs:
httpd.conf - the main apache config file
php.ini - the main PHP config file
PHP can be configured with a remarkable number of options at build time. These are handled by autoconf and can be listed with the --help flag.
./configure --help
A typical build for the shared library using the APache eXtenSion tool and the PHP internal MySQL support may be something like:
./configure --with-mysql --with-apxs=/var/lib/apache/sbin/apxs --enable-trans-sid make make install
To use PHP with Apache you need to add some stanzas to the Apache configuration file httpd.conf. The recommended mode of use at one time was through CGI. From PHP4.2.x onwards installing PHP as an Apache module is recommended for security reasons. There are several way to achieve this. The static library libphp4.a can be compiled into Apache but this means recompiling Apache if PHP is upgraded. The shared library libphp4.so is recommended. This has the added advantage that you can experiment with several different libphp4.so files having different configurations.
Apache needs to be told about the PHP module. Add the following stanza to the rest of the LoadModule stanzas in httpd.conf.
LoadModule php4_module libexec/libphp4.so
Now the module can be added to the module list.
AddModule mod_php4.c
An Addtype stanza tells Apache how to handle the PHP MIME type.
Addtype application/x-httpd-php .php .php4 .phtml
Now the Apache server can be restarted and PHP scripts will run from any published filesystem. The first thing to do is to test the installation to make sure that it is working. The PHP function phpinfo() makes this easy. At the Unix prompt...
cd ~/public_html echo "<?php phpinfo() ?>" > info.php chmod 644 info.php
Note that PHP scripts do not need to be made executable (like perl) but they do need to be readable by Apache (httpd), chmod 644 is sufficient. If this is mysterious to you then brush up on your elementary Unix skills Now surf to the file info.php and see what happens. Further configuration of the PHP can be achieved by copying the sample php.ini file that arrived with the distribution into /usr/local/lib. For example, from PHP4.2.x onwards PHP cannot be built with register-globals enabled but the stanza:
register_globals = On
in php.ini registers environment, get, post, cookie and session (EGPCS) variables as global - although this is not recommended for security reasons it will provide backward compatibility with older PHP scripts.
stuweb.cms.gre.ac.uk currently does not have EGPCS registered global.