2521N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2521N/A<
TITLE>Compiling and Installing Apache</
TITLE>
2521N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) --> 2521N/A<
H1 ALIGN="CENTER">Compiling and Installing Apache 1.3</
H1>
2521N/Afor various UnixWare versions before compiling.
2521N/AInformation on the latest version of Apache can be found on the Apache
2521N/Alist the current release, any more recent beta-test release, together
2521N/Awith details of mirror web and anonymous ftp sites.
2521N/AIf you downloaded a binary distribution, skip to <
A 2521N/AHREF="#install">Installing Apache</
A>. Otherwise read the next section
2521N/Afor how to compile the server.
2521N/ACompiling Apache consists of three steps: Firstly select which Apache
2521N/A<
STRONG>modules</
STRONG> you want to include into the server. Secondly create a
2521N/Aconfiguration for your operating system. Thirdly compile the
2521N/AAll configuration of Apache is performed in the <
CODE>src</
CODE>
2521N/Adirectory of the Apache distribution. Change into this directory.
2521N/A Select modules to compile into Apache in the
2521N/A <
CODE>Configuration</
CODE> file. Uncomment lines corresponding to
2521N/A those optional modules you wish to include (among the AddModule lines
2521N/A at the bottom of the file), or add new lines corresponding to
2521N/A additional modules you have downloaded or written. (See <
A 2521N/A write Apache modules). Advanced users can comment out some of the
2521N/A default modules if they are sure they will not need them (be careful
2521N/A though, since many of the default modules are vital for the correct
2521N/A operation and security of the server).
2521N/A You should also read the instructions in the <
CODE>Configuration</
CODE>
2521N/A file to see if you need to set any of the <
CODE>Rule</
CODE> lines.
2521N/A Configure Apache for your operating system. Normally you can just
2521N/A type run the <
CODE>Configure</
CODE> script as given below. However
2521N/A if this fails or you have any special requirements (
e.g. to include
2521N/A an additional library required by an optional module) you might need
2521N/A to edit one or more of the following options in the
2521N/A <
CODE>Configuration</
CODE> file:
2521N/A <
CODE>EXTRA_CFLAGS, LIBS, LDFLAGS, INCLUDES</
CODE>.
2521N/A Run the <
CODE>Configure</
CODE> script:
2521N/A Using 'Configuration' as config file
2521N/A + configured for <whatever> platform
2521N/A + setting C compiler to <whatever> *
2521N/A + setting C compiler optimization-level to <whatever> *
2521N/A + doing sanity check on compiler and options
2521N/A Creating Makefile in support
2521N/A (*: Depending on Configuration and your system, Configure
2521N/A make not print these lines. That's OK).<
P>
2521N/A This generates a Makefile for use in stage 3. It also creates a
2521N/A Makefile in the support directory, for compilation of the optional
2521N/A (If you want to maintain multiple configurations, you can give a
2521N/A option to <
CODE>Configure</
CODE> to tell it to read an alternative
2521N/A Configuration file, such as <
CODE>Configure -file
2521N/AThe modules we place in the Apache distribution are the ones we have
2521N/Atested and are used regularly by various members of the Apache
2521N/Adevelopment group. Additional modules contributed by members or third
2521N/Aparties with specific needs or functions are available at <
A 2521N/AThere are instructions on that page for linking these modules into the
2521N/A<
H2><
A NAME="install">Installing Apache</
A></
H2>
2521N/AYou will have a binary file called <
CODE>httpd</
CODE> in the
2521N/A<
CODE>src</
CODE> directory. A binary distribution of Apache will
2521N/AThe next step is to install the program and configure it. Apache is
2521N/Adesigned to be configured and run from the same set of directories
2521N/Awhere it is compiled. If you want to run it from somewhere else, make
2521N/Aa directory and copy the <
CODE>conf</
CODE>, <
CODE>logs</
CODE> and
2521N/A<
CODE>icons</
CODE> directories into it. In either case you should
2521N/Adescribing how to set the permissions on the server root directory.<
P>
2521N/AThe next step is to edit the configuration files for the server. This
2521N/Aconsists of setting up various <
STRONG>directives</
STRONG> in up to three
2521N/Acentral configuration files. By default, these files are located in
2521N/Athe <
CODE>conf</
CODE> directory and are called <
CODE>
srm.conf</
CODE>,
2521N/Astarted there are same files in the <
CODE>conf</
CODE> directory of the
2521N/Aor rename these files to the names without the <
CODE>-dist</
CODE>.
2521N/AThen edit each of the files. Read the comments in each file carefully.
2521N/AFailure to setup these files correctly could lead to your server not
2521N/Aworking or being insecure. You should also have an additional file in
2521N/Afile usually does not need editing.
2521N/Aabout the server: the port number, the user it runs as, etc. Next
2521N/Adocument tree, special functions like server-parsed HTML or internal
2521N/Afile to at least set the base cases of access.
2521N/AIn addition to these three files, the server behavior can be configured
2521N/Aon a directory-by-directory basis by using <
CODE>.htaccess</
CODE>
2521N/Afiles in directories accessed by the server.
2521N/A<
H3>Starting and Stopping the Server</
H3>
2521N/ATo start the server, simply run <
CODE>httpd</
CODE>. This will look for
2521N/Athis file is somewhere else, you can give the real
2521N/Alocation with the -f argument. For example:
2521N/AIf all goes well this will return to the command prompt almost
2521N/Aimmediately. This indicates that the server is now up and running. If
2521N/Aanything goes wrong during the initialization of the server you will
2521N/Asee an error message on the screen.
2521N/AIf the server started ok, you can now use your browser to
2521N/Aconnect to the server and read the documentation. If you are running
2521N/Athe browser on the same machine as the server and using the default
2521N/Aport of 80, a suitable URL to enter into your browser is
2521N/ANote that when the server starts it will create a number of
<
EM>child</
EM> 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.<
EM>N</
EM></
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