259N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
259N/A<
TITLE>Compiling and Installing Apache</
TITLE>
259N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) --> 259N/A<
H1 ALIGN="CENTER">Compiling and Installing Apache 1.2</
H1>
259N/A<
P>If you wish to download and install an earlier version of Apache please
5680N/Afor various UnixWare versions before compiling.
259N/AInformation on the latest version of Apache can be found on the Apache
618N/Alist the current release, any more recent beta-test release, together
817N/Awith details of mirror web and anonymous ftp sites.
259N/AIf you downloaded a binary distribution, skip to <
A 5939N/AHREF="#install">Installing Apache</
A>. Otherwise read the next section
2899N/Afor how to compile the server.
259N/ACompiling Apache consists of three steps: Firstly select which Apache
259N/A<
b>modules</
b> you want to include into the server. Secondly create a
5680N/Aconfiguration for your operating system. Thirdly compile the
2669N/AAll configuration of Apache is performed in the <
CODE>src</
CODE>
5680N/Adirectory of the Apache distribution. Change into this directory.
5939N/A Select modules to compile into Apache in the
5939N/A <
CODE>Configuration</
CODE> file. Uncomment lines corresponding to
5939N/A those optional modules you wish to include (among the AddModule lines
5939N/A at the bottom of the file), or add new lines corresponding to
5680N/A additional modules you have downloaded or written. (See <
A 5680N/A write Apache modules). Advanced users can comment out some of the
5680N/A default modules if they are sure they will not need them (be careful
5680N/A though, since many of the default modules are vital for the correct
5680N/A operation and security of the server).
259N/A You should also read the instructions in the <
CODE>Configuration</
CODE>
259N/A file to see if you need to set any of the <
CODE>Rule</
CODE> lines.
259N/A Configure Apache for your operating system. Normally you can just
259N/A type run the <
CODE>Configure</
CODE> script as given below. However
259N/A if this fails or you have any special requirements (
e.g. to include
259N/A an additional library required by an optional module) you might need
259N/A to edit one or more of the following options in the
259N/A <
CODE>Configuration</
CODE> file:
259N/A <
CODE>EXTRA_CFLAGS, LIBS, LDFLAGS, INCLUDES</
CODE>.
259N/A Run the <
CODE>Configure</
CODE> script:
259N/A Using 'Configuration' as config file
5939N/A + configured for <whatever> platform
5939N/A + setting C compiler to <whatever> *
5939N/A + setting C compiler optimization-level to <whatever> *
5939N/A + doing sanity check on compiler and options
5939N/A Creating Makefile in support
259N/A Creating Makefile in main
5939N/A (*: Depending on Configuration and your system, Configure
259N/A make not print these lines. That's OK).<
P>
259N/A This generates a Makefile for use in stage 3. It also creates a
5939N/A Makefile in the support directory, for compilation of the optional
3817N/A (If you want to maintain multiple configurations, you can give a
3817N/A option to <
CODE>Configure</
CODE> to tell it to read an alternative
3817N/A Configuration file, such as <
CODE>Configure -file
The modules we place in the Apache distribution are the ones we have
tested and are used regularly by various members of the Apache
development group. Additional modules contributed by members or third
parties with specific needs or functions are available at <
AThere are instructions on that page for linking these modules into the
<
h2><
A NAME="install">Installing Apache</
A></
h2>
You will have a binary file called <
CODE>httpd</
CODE> in the
<
CODE>src</
CODE> directory. A binary distribution of Apache will
The next step is to install the program and configure it. Apache is
designed to be configured and run from the same set of directories
where it is compiled. If you want to run it from somewhere else, make
a directory and copy the <
CODE>conf</
CODE>, <
CODE>logs</
CODE> and
<
CODE>icons</
CODE> directories into it. <
P>
The next step is to edit the configuration files for the server. This
consists of setting up various <
B>directives</
B> in up to three
central configuration files. By default, these files are located in
the <
CODE>conf</
CODE> directory and are called <
CODE>
srm.conf</
CODE>,
started there are same files in the <
CODE>conf</
CODE> directory of the
or rename these files to the names without the <
CODE>-dist</
CODE>.
Then edit each of the files. Read the comments in each file carefully.
Failure to setup these files correctly could lead to your server not
working or being insecure. You should also have an additional file in
the <
CODE>conf</
CODE> directory called <
CODE>
mime.types</
CODE>. This
file usually does not need editing.
First edit <
CODE>
httpd.conf</
CODE>. This sets up general attributes
about the server: the port number, the user it runs as, etc. Next
edit the <
CODE>
srm.conf</
CODE> file; this sets up the root of the
document tree, special functions like server-parsed HTML or internal
imagemap parsing, etc. Finally, edit the <
CODE>
access.conf</
CODE>
file to at least set the base cases of access.
In addition to these three files, the server behavior can be configured
on a directory-by-directory basis by using <
CODE>.htaccess</
CODE>
files in directories accessed by the server.
<
H3>Starting and Stopping the Server</
H3>
To start the server, simply run <
CODE>httpd</
CODE>. This will look for
<
CODE>
httpd.conf</
CODE> in the location compiled into the code (by
this file is somewhere else, you can give the real
location with the -f argument. For example:
If all goes well this will return to the command prompt almost
immediately. This indicates that the server is now up and running. If
anything goes wrong during the initialization of the server you will
see an error message on the screen.
If the server started ok, you can now use your browser to
connect to the server and read the documentation. If you are running
the browser on the same machine as the server and using the default
port of 80, a suitable URL to enter into your browser is
Note that when the server starts it will create a number of
<
i>child</
i> processes to handle the requests. If you started Apache
as the root user, the parent process will continue to run as root
while the children will change to the user as given in the
httpd.confIf when you run <
CODE>httpd</
CODE> it complained about being unable to
"bind" to an address, then either some other process is already using
the port you have configured Apache to use, or you are running httpd
as a normal user but trying to use port below 1024 (such as the
If the server is not running, read the error message displayed
when you run httpd. You should also check the server
error_log for additional information (with the default configuration,
this will be located in the file <
CODE>error_log</
CODE> in the
<
CODE>logs</
CODE> directory).
If you want your server to continue running after a system reboot, you
should add a call to <
CODE>httpd</
CODE> to your system startup files
(typically <
CODE>
rc.local</
CODE> or a file in an
<
CODE>rc.<
I>N</
I></
CODE> directory). This will start Apache as root.
Before doing this ensure that your server is properly configured
for security and access restrictions.
To stop Apache send the parent process a TERM signal. The PID of this
process is written to the file <
CODE>
httpd.pid</
CODE> in the
<
CODE>logs</
CODE> directory (unless configured otherwise). Do not
attempt to kill the child processes because they will be renewed by
the parent. A typical command to stop the server is:
For more information about Apache command line options, configuration
and log files, see <
A HREF="invoking.html">Starting Apache</
A>. For a
reference guide to all Apache directives supported by the distributed
<
H2>Compiling Support Programs</
H2>
In addition to the main <
CODE>httpd</
CODE> server which is compiled
and configured as above, Apache includes a number of support programs.
These are not compiled by default. The support programs are in the
<
CODE>support</
CODE> directory of the distribution. To compile
the support programs, change into this directory and type