Installing Apache With PHP

This tutorial assumes PHP 4 and Apache 1.3x are being installed on a
Linux system.
It also assumes that either MySQL or PostgreSQL have already been

1. Download Apache
Download the apache source in .tar.gz format from
If you download Apache 2, bear in mind that you may need to change the
version numbers accordingly in all of the commands for the installation

2. Download PHP
Download the PHP source from in .tar.gz format.
If you download a different version to the one used in this tutorial,
remember to change the version numbers accordingly when executing commands
for the installation procedure.

3. Pre-Install
Copy both .tar.gz files to the same directory
Ensure you are logged in as a user with enough privileges to compile
software (most users are).

4. Extract The Archives
run the following commands:
tar xfz- apache_1.3.22.tar.gz
tar xfz- php-4.11.tar.gz
This *should* be the same as:
gunzip -c apache_1.3.22.tar.gz | tar xf -
gunzip -c php-4.11.tar.gz | tar xf -
5. Configure Apache
Type the following:
cd ./apache_1.3.22
./configure --prefix=/usr/local/apache
6. Configure PHP
To configure with MySQL, type the following:
cd ../php-4.1.1
./configure --with-apache=../apache_1.3.22 --enable-inline-optimization 
If you use PostgreSQL, type:
cd ../php-4.1.1
./configure --with-apache=../apache_1.3.22 --enable-inline-optimization 
In both cases, remember to change the =/usr to the directory where the
MySQL or PostgreSQL directory can be found, e.g. if PostgreSQL is
installed in /usr/local/pgsql, you will type /usr/local.

7. Build And Install PHP
Type the following:
make install
Once this has run, the compiled Apache PHP module will be copied to the
Apache source directory, and the PEAR libraries will be installed in an
appropriate place.

8. Reconfigure Apache
You now need to reconfigure Apache, telling it about the PHP module:
cd ../apache_1.3.22
./configure --prefix=/usr/local/apache 
9. Compile Apache
Apache can now be compiled and installed using the following:
make install
10. Configure Apache
Configure Apache's httpd.conf file, which should be located at
You will need to set your particular options depending on your server, see
the Apache documentation for more details.
You will also need to add the following line to the httpd.conf:
AddType application/x-httpd-php .php
You may also want to edit the line that says:
DirectoryIndex index.html
to read:
DirectoryIndex index.html index.php
11. Check PHP Configuration
There should be a file called php.ini somewhere in the directory tree
under which PHP installed itself, probably /usr/local/php.
Check this file for settings you may need to change, although the default
file is fine for most purposes. Some security-minded people may wish to
disable certain options.

12. Start Apache
Start apache as follows:
/usr/local/apache/bin/apachectl start
A. Appendix A - Stopping Apache
If you need to stop apache, type:
/usr/local/apache/bin/apachectl stop
B. Appendix B - Installing PHP Into An Existing Apache
If you already have a working installation of Apache, and do not want to
spend hours reconfiguring, you can simply change the ./configure line of
the PHP configuration to:
./configure --with-apxs --enable-inline-optimization --with-mysql=/usr
Remember to change the mysql to pgsql if you use PostgreSQL, and to change
the /usr to the relevant path for your system.
If you have done this, you do not need to configure or build Apache, the
PHP module will be installed with the apxs script into your existing
Apache server.
Remember that you will still need to add the line:
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
to your httpd.conf file.

C. Appendix C - About This Document
Author: Andrew Bennieston
Date: 08-07-2002
Time: 17:07
Distribution: AntiOnline, Firestorm UK