This site will work and look better in a browser that supports web standards, but it should be accessible for any browser or Internet device.
If you're seeing this message, you may have to scroll to the bottom of the page to see the navigation links.

Apache Links and Notes

This is a collection of notes and links that we find useful with Apache.


If you need to protect a directory or document, you'll want to setup User Authentication. Check out the Apache Week tutorial. If things grow, you might want to move over the using a database for the passwords.


Apache and PHP3

Makes sure to fix the modules section to cover mod_php and mod_perl. You should just have to uncomment the appropriate Add_Module and Load_Module lines in the Extra Modules sections:

# Extra Modules
LoadModule php_module modules/ LoadModule php3_module modules/
LoadModule perl_module modules/
# Extra Modules
AddModule mod_php.c AddModule mod_php3.c
AddModule mod_perl.c

Then, make sure you modify the srm.conf file in the same directory by uncommenting the mod_php and mod_perl lines:

# For example, the PHP3 module (not part of the Apache distribution)
# will typically use:
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3 .phtml
AddType application/x-httpd-php3-source .phps
# The following is for PHP/FI (PHP2):
#AddType application/x-httpd-php .phtml

# To use server-parsed HTML files
AddType text/html .shtml
AddHandler server-parsed .shtml

# To enable the perl module (if you have it installed), uncomment
# the following section
Alias /perl/ /home/httpd/perl/
<Location /perl>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI

Apache and PHP4

Installing Apache with PHP and Postgres-SQL support and MySQL support (don't ask...). Also includes hash, mcrypt (as opposed to the limited one-way crypt function) and aspell. Unclear until testing if this includes imagemagick support... My system may already have those libraries installed!

In general, it's a good idea to check the PHP Manual on each module you want to have support for because many will have quirks that will stop the install. Go to and search on the name of the module (e.g. mhash or mcrypt) and chose the first link that begins PHP Manual:

This is for the following (note some of these are not current! more current version of aspell and (lib)mcrypt have some broken mechanisms and php will not compile with them)

mhash-0.8.2 (homepage, tar.gz)

aspell-.26.2 (homepage, tar.gz)


libmcrypt-2.2.7 ( alt homepage, tar.gz)

mcrypt-2.2.5 (homepage), alt homepage, tar.gz


apache_1.3.20 (homepage, tar.gz)

PostgreSQL (homepage, download)

PHP 4.0.6 (homepage, download page)

On the first set of modules tar -zxvf each file (if you do *.tar.gz it fails!) then on the resulting directories --in the order above-- do the following. Aspell is flaky, so it may or may not compile on your machine depending on your setup.

cd dir (e.g. cd mhash-0.8.2)



make install

do not: make clean until done

On the second set of modules --libmcrypt and mcrypt-- the process is slightly different:

./configure --disable-posix-threads (on both)


make install

do not: make clean until done

make sure that there's a file called aspell-c.h in /usr/local/include/ if not copy it from the source directory (aspell-.26.2 above) to /usr/local/include

--> copy mcrypt.h to the php directory


If you run into a "C++ compiler cannot create executables." error with either PostgreSQL or aspell and you're running Mandrake, this may help. You probably just need to install the C++ compilter and standard libraries (this, this and this). Easy for me to say, eh? Better yet, hit a Mandrake mirror and download everything that begins with postgresql and use the command rpm -ihv to install each one.


The following assumes that apache is in /home/downloads/. Change from that directory into the apache directory:

cd apache_1.3.20

from the apache directory, do an initial configure

./configure --prefix=/www

Then go to the php directory:

cd ../php-4.0.6/

from the php directory, configure and make php. PHP disables inline optimizations by default (due to the GCC compiler failing when the target is one of the new 64 bit processors), but inline optimizations result in a two to five fold inccrease in speed. If you're running on a 64 bit processor, remove `--enable-inline-optimization' from the following.

./configure --with-pgsql --with-mysql --with-mhash --with-apache=/home/downloads/apache_1.3.20/ --enable-track-vars --with-mcrypt --enable-inline-optimization
make install

Change to the apache directory:

cd ../apache_1.3.20

Then do the final apache config and install.

./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a --enable-module=so --enable-module=rewrite


make install

You can edit /usr/local/lib/php.ini file to set PHP options. Edit your httpd.conf or srm.conf file and add:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

The later color-highlights the syntax of anything ending in .phps. If you've previously installed php and you're using a custom extension for php (e.g. .phtml), make sure you also add an AddType line for that extension

To start apache:

cd PREFIX/bin/apachectl start (where PREFIX is /www or whatever root directory apache is in)

Make sure that you add this to your startup routines. In redhat, this involves replacing the existing apache or httpd startup script with a link to PREFIX/bin/apachectl. Assuming that PREFIX is www:

cd /etc/rc.d/init.d
ln -s /www/bin/apachectl ./httpd


Old Notes

If you don't now where the Apache source files are, do a "find // -name httpd.h -print" and use the path to the directory above the one that contains httpd. If you're compiling with PostgreSQL support like below, make sure PostrgreSQL is installed on the local machine. It will not work if it isn't. Try to use the latest version of PostgreSQL if at all possible because of all the bug fixes. I got this to work:

./configure --with-pgsql --with-mhash --with-apache=/home/downloads/apache_n_php/apache_1.3.12/ --enable-track-vars --with-mcrypt

I wanted this to work:

./configure --with-pgsql --with-mcrypt=/home/downloads/apache_n_php/php-4.0.1pl2/mcrypt.h --with-mhash --with-apache=/home/downloads/apache_n_php/apache_1.3.12/ --enable-track-vars

Then we change to the apache directory you un-tared above and configure:

./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a --enable-module=so --enable-module=rewrite

Next, finish most of this off

cd ../php-4.0.x

cp php.ini-dist /usr/local/lib/php.ini

cd ../apache_1.3.12


make install



The Apache Desktop Reference