229N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
229N/A<
TITLE>Compiling and Installing Apache</
TITLE>
229N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) --> 229N/A<
blockquote><
strong>Warning:</
strong>
229N/AThis document has not been updated to take into account changes
873N/Amade in the 2.0 version of the Apache HTTP Server. Some of the
229N/Ainformation may still be relevant, but please use it
229N/A<
H1 ALIGN="CENTER">Compiling and Installing Apache 1.3</
H1>
229N/AThis document covers compilation and installation of Apache on Unix
229N/Asystems only. For compiling and installation on Windows, see <
A 229N/Afor various UnixWare versions before compiling.
229N/A<
H2>Downloading Apache</
H2>
229N/AInformation on the latest version of Apache can be found on the Apache
229N/Alist the current release, any more recent beta-test release, together
229N/Awith details of mirror web and anonymous ftp sites.
229N/AIf you downloaded a binary distribution, skip to <
A 229N/AHREF="#install">Installing Apache</
A>. Otherwise read the next section
229N/Afor how to compile the server.
229N/A<
H2>Compiling Apache</
H2>
229N/ACompiling Apache consists of three steps: Firstly select which Apache
229N/A<
STRONG>modules</
STRONG> you want to include into the server. Secondly create a
232N/Aconfiguration for your operating system. Thirdly compile the
229N/AAll configuration of Apache is performed in the <
CODE>src</
CODE>
229N/Adirectory of the Apache distribution. Change into this directory.
229N/A Select modules to compile into Apache in the
229N/A <
CODE>Configuration</
CODE> file. Uncomment lines corresponding to
229N/A those optional modules you wish to include (among the AddModule lines
229N/A at the bottom of the file), or add new lines corresponding to
229N/A additional modules you have downloaded or written. (See <
A 229N/A write Apache modules). Advanced users can comment out some of the
229N/A default modules if they are sure they will not need them (be careful
229N/A though, since many of the default modules are vital for the correct
229N/A operation and security of the server).
229N/A You should also read the instructions in the <
CODE>Configuration</
CODE>
229N/A file to see if you need to set any of the <
CODE>Rule</
CODE> lines.
229N/A Configure Apache for your operating system. Normally you can just
229N/A run the <
CODE>Configure</
CODE> script as given below. However
229N/A if this fails or you have any special requirements (<
EM>
e.g.</
EM>, to include
229N/A an additional library required by an optional module) you might need
229N/A to edit one or more of the following options in the
229N/A <
CODE>Configuration</
CODE> file:
229N/A <
CODE>EXTRA_CFLAGS, LIBS, LDFLAGS, INCLUDES</
CODE>.
229N/A Run the <
CODE>Configure</
CODE> script:
229N/A Using 'Configuration' as config file
229N/A + configured for <whatever> platform
229N/A + setting C compiler to <whatever> *
229N/A + setting C compiler optimization-level to <whatever> *
229N/A + Adding selected modules
229N/A + doing sanity check on compiler and options
229N/A Creating Makefile in support
229N/A Creating Makefile in main
229N/A (*: Depending on Configuration and your system, Configure
229N/A might not print these lines. That's OK).<
P>
229N/A This generates a Makefile for use in stage 3. It also creates a
229N/A Makefile in the support directory, for compilation of the optional
229N/A (If you want to maintain multiple configurations, you can give an
229N/A option to <
CODE>Configure</
CODE> to tell it to read an alternative
229N/A Configuration file, such as <
CODE>Configure -file
229N/A Type <
CODE>make</
CODE>.
229N/AThe modules we place in the Apache distribution are the ones we have
229N/Atested and are used regularly by various members of the Apache
229N/Adevelopment group. Additional modules contributed by members or third
229N/Aparties with specific needs or functions are available at
229N/AThere are instructions on that page for linking these modules into the
229N/A<
H2><
A NAME="install">Installing Apache</
A></
H2>
229N/AYou will have a binary file called <
CODE>httpd</
CODE> in the
229N/A<
CODE>src</
CODE> directory. A binary distribution of Apache will
229N/AThe next step is to install the program and configure it. Apache is
229N/Adesigned to be configured and run from the same set of directories
229N/Awhere it is compiled. If you want to run it from somewhere else, make
229N/Aa directory and copy the <
CODE>conf</
CODE>, <
CODE>logs</
CODE> and
229N/A<
CODE>icons</
CODE> directories into it. In either case you should
229N/Adescribing how to set the permissions on the server root directory.<
P>
229N/AThe next step is to edit the configuration files for the server. This
229N/Aconsists of setting up various <
STRONG>directives</
STRONG> in up to three
229N/Acentral configuration files. By default, these files are located in
229N/Athe <
CODE>conf</
CODE> directory and are called <
CODE>
srm.conf</
CODE>,
229N/Astarted there are same files in the <
CODE>conf</
CODE> directory of the
229N/Aor rename these files to the names without the <
CODE>-dist</
CODE>.
229N/AThen edit each of the files. Read the comments in each file carefully.
229N/AFailure to setup these files correctly could lead to your server not
229N/Aworking or being insecure. You should also have an additional file in
229N/Afile usually does not need editing.
229N/Aabout the server: the port number, the user it runs as, <
EM>etc.</
EM> Next
229N/Aedit the <
CODE>
srm.conf</
CODE> file; this sets up the root of the
229N/Adocument tree, special functions like server-parsed HTML or internal
229N/Afile to at least set the base cases of access.
229N/AIn addition to these three files, the server behavior can be configured
229N/Aon a directory-by-directory basis by using <
CODE>.htaccess</
CODE>
229N/Afiles in directories accessed by the server.
229N/A<
H3>Set your system time properly!</
H3>
229N/AProper operation of a public web server requires accurate time
229N/Akeeping, since elements of the HTTP protocol are expressed as the time
229N/Aof day. So, it's time to investigate setting up NTP or some other
229N/Atime synchronization system on your Unix box, or whatever the
229N/Aequivalent on NT would be.
232N/A<
H3>Starting and Stopping the Server</
H3>
229N/ATo start the server, simply run <
CODE>httpd</
CODE>. This will look for
229N/Athis file is somewhere else, you can give the real
229N/Alocation with the -f argument. For example:
229N/AIf all goes well this will return to the command prompt almost
229N/Aimmediately. This indicates that the server is now up and running. If
229N/Aanything goes wrong during the initialization of the server you will
229N/Asee an error message on the screen.
229N/AIf the server started ok, you can now use your browser to
229N/Aconnect to the server and read the documentation. If you are running
229N/Athe browser on the same machine as the server and using the default
229N/Aport of 80, a suitable URL to enter into your browser is
229N/ANote that when the server starts it will create a number of
232N/A<
EM>child</
EM> processes to handle the requests. If you started Apache
232N/Aas the root user, the parent process will continue to run as root
229N/AIf when you run <
CODE>httpd</
CODE> it complained about being unable to
232N/A"bind" to an address, then either some other process is already using
232N/Athe port you have configured Apache to use, or you are running httpd
229N/Aas a normal user but trying to use a port below 1024 (such as the
229N/AIf the server is not running, read the error message displayed
229N/Awhen you run httpd. You should also check the server
229N/Aerror_log for additional information (with the default configuration,
229N/Athis will be located in the file <
CODE>error_log</
CODE> in the
229N/A<
CODE>logs</
CODE> directory).
232N/AIf you want your server to continue running after a system reboot, you
229N/Ashould add a call to <
CODE>httpd</
CODE> to your system startup files
232N/A<
CODE>rc.<
EM>N</
EM></
CODE> directory). This will start Apache as root.
229N/ABefore doing this ensure that your server is properly configured
229N/Afor security and access restrictions.
229N/ATo stop Apache send the parent process a TERM signal. The PID of this
229N/A<
CODE>logs</
CODE> directory (unless configured otherwise). Do not
229N/Aattempt to kill the child processes because they will be renewed by
229N/Athe parent. A typical command to stop the server is:
229N/AFor more information about Apache command line options, configuration
229N/Areference guide to all Apache directives supported by the distributed
229N/A<
H2>Compiling Support Programs</
H2>
229N/AIn addition to the main <
CODE>httpd</
CODE> server which is compiled
229N/Aand configured as above, Apache includes a number of support programs.
232N/AThese are not compiled by default. The support programs are in the
232N/A<
CODE>support</
CODE> directory of the distribution. To compile
229N/Athe support programs, change into this directory and type