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