1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
4 <TITLE>Compiling and Installing Apache</TITLE>
7 <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
15 <!--#include virtual="header.html" -->
17 <H1 ALIGN="CENTER">Compiling and Installing Apache 1.3</H1>
19 UnixWare users will want to consult <A HREF="unixware.html">build notes</A>
20 for various UnixWare versions before compiling.
22 <H2>Downloading Apache</H2>
24 Information on the latest version of Apache can be found on the Apache
26 HREF="http://www.apache.org/">http://www.apache.org/</A>. This will
27 list the current release, any more recent beta-test release, together
28 with details of mirror web and anonymous ftp sites.
32 If you downloaded a binary distribution, skip to <A
33 HREF="#install">Installing Apache</A>. Otherwise read the next section
34 for how to compile the server.
36 <h2>Compiling Apache</h2>
38 Compiling Apache consists of three steps: Firstly select which Apache
39 <STRONG>modules</STRONG> you want to include into the server. Secondly create a
40 configuration for your operating system. Thirdly compile the
44 All configuration of Apache is performed in the <CODE>src</CODE>
45 directory of the Apache distribution. Change into this directory.
49 Select modules to compile into Apache in the
50 <CODE>Configuration</CODE> file. Uncomment lines corresponding to
51 those optional modules you wish to include (among the AddModule lines
52 at the bottom of the file), or add new lines corresponding to
53 additional modules you have downloaded or written. (See <A
54 HREF="misc/API.html">API.html</A> for preliminary docs on how to
55 write Apache modules). Advanced users can comment out some of the
56 default modules if they are sure they will not need them (be careful
57 though, since many of the default modules are vital for the correct
58 operation and security of the server).
61 You should also read the instructions in the <CODE>Configuration</CODE>
62 file to see if you need to set any of the <CODE>Rule</CODE> lines.
66 Configure Apache for your operating system. Normally you can just
67 type run the <CODE>Configure</CODE> script as given below. However
68 if this fails or you have any special requirements (e.g. to include
69 an additional library required by an optional module) you might need
70 to edit one or more of the following options in the
71 <CODE>Configuration</CODE> file:
72 <CODE>EXTRA_CFLAGS, LIBS, LDFLAGS, INCLUDES</CODE>.
75 Run the <CODE>Configure</CODE> script:
79 Using 'Configuration' as config file
80 + configured for <whatever> platform
81 + setting C compiler to <whatever> *
82 + setting C compiler optimization-level to <whatever> *
83 + Adding selected modules
84 + doing sanity check on compiler and options
85 Creating Makefile in support
86 Creating Makefile in main
87 Creating Makefile in os/unix
88 Creating Makefile in modules/standard
92 (*: Depending on Configuration and your system, Configure
93 make not print these lines. That's OK).<P>
95 This generates a Makefile for use in stage 3. It also creates a
96 Makefile in the support directory, for compilation of the optional
100 (If you want to maintain multiple configurations, you can give a
101 option to <CODE>Configure</CODE> to tell it to read an alternative
102 Configuration file, such as <CODE>Configure -file
103 Configuration.ai</CODE>).
107 Type <CODE>make</CODE>.
110 The modules we place in the Apache distribution are the ones we have
111 tested and are used regularly by various members of the Apache
112 development group. Additional modules contributed by members or third
113 parties with specific needs or functions are available at <A
114 HREF="http://www.apache.org/dist/contrib/modules/"><URL:http://www.apache.org/dist/contrib/modules/></A>.
115 There are instructions on that page for linking these modules into the
118 <h2><A NAME="install">Installing Apache</A></h2>
120 You will have a binary file called <CODE>httpd</CODE> in the
121 <CODE>src</CODE> directory. A binary distribution of Apache will
122 supply this file. <P>
124 The next step is to install the program and configure it. Apache is
125 designed to be configured and run from the same set of directories
126 where it is compiled. If you want to run it from somewhere else, make
127 a directory and copy the <CODE>conf</CODE>, <CODE>logs</CODE> and
128 <CODE>icons</CODE> directories into it. In either case you should
129 read the <A HREF="misc/security_tips.html#serverroot">security tips</A>
130 describing how to set the permissions on the server root directory.<P>
132 The next step is to edit the configuration files for the server. This
133 consists of setting up various <STRONG>directives</STRONG> in up to three
134 central configuration files. By default, these files are located in
135 the <CODE>conf</CODE> directory and are called <CODE>srm.conf</CODE>,
136 <CODE>access.conf</CODE> and <CODE>httpd.conf</CODE>. To help you get
137 started there are same files in the <CODE>conf</CODE> directory of the
138 distribution, called <CODE>srm.conf-dist</CODE>,
139 <CODE>access.conf-dist</CODE> and <CODE>httpd.conf-dist</CODE>. Copy
140 or rename these files to the names without the <CODE>-dist</CODE>.
141 Then edit each of the files. Read the comments in each file carefully.
142 Failure to setup these files correctly could lead to your server not
143 working or being insecure. You should also have an additional file in
144 the <CODE>conf</CODE> directory called <CODE>mime.types</CODE>. This
145 file usually does not need editing.
149 First edit <CODE>httpd.conf</CODE>. This sets up general attributes
150 about the server: the port number, the user it runs as, etc. Next
151 edit the <CODE>srm.conf</CODE> file; this sets up the root of the
152 document tree, special functions like server-parsed HTML or internal
153 imagemap parsing, etc. Finally, edit the <CODE>access.conf</CODE>
154 file to at least set the base cases of access.
158 In addition to these three files, the server behavior can be configured
159 on a directory-by-directory basis by using <CODE>.htaccess</CODE>
160 files in directories accessed by the server.
162 <H3>Starting and Stopping the Server</H3>
164 To start the server, simply run <CODE>httpd</CODE>. This will look for
165 <CODE>httpd.conf</CODE> in the location compiled into the code (by
166 default <CODE>/usr/local/apache/conf/httpd.conf</CODE>). If
167 this file is somewhere else, you can give the real
168 location with the -f argument. For example:
171 /usr/local/apache/httpd -f /usr/local/apache/conf/httpd.conf
174 If all goes well this will return to the command prompt almost
175 immediately. This indicates that the server is now up and running. If
176 anything goes wrong during the initialization of the server you will
177 see an error message on the screen.
179 If the server started ok, you can now use your browser to
180 connect to the server and read the documentation. If you are running
181 the browser on the same machine as the server and using the default
182 port of 80, a suitable URL to enter into your browser is
190 Note that when the server starts it will create a number of
191 <EM>child</EM> processes to handle the requests. If you started Apache
192 as the root user, the parent process will continue to run as root
193 while the children will change to the user as given in the httpd.conf
198 If when you run <CODE>httpd</CODE> it complained about being unable to
199 "bind" to an address, then either some other process is already using
200 the port you have configured Apache to use, or you are running httpd
201 as a normal user but trying to use port below 1024 (such as the
206 If the server is not running, read the error message displayed
207 when you run httpd. You should also check the server
208 error_log for additional information (with the default configuration,
209 this will be located in the file <CODE>error_log</CODE> in the
210 <CODE>logs</CODE> directory).
214 If you want your server to continue running after a system reboot, you
215 should add a call to <CODE>httpd</CODE> to your system startup files
216 (typically <CODE>rc.local</CODE> or a file in an
217 <CODE>rc.<EM>N</EM></CODE> directory). This will start Apache as root.
218 Before doing this ensure that your server is properly configured
219 for security and access restrictions.
223 To stop Apache send the parent process a TERM signal. The PID of this
224 process is written to the file <CODE>httpd.pid</CODE> in the
225 <CODE>logs</CODE> directory (unless configured otherwise). Do not
226 attempt to kill the child processes because they will be renewed by
227 the parent. A typical command to stop the server is:
230 kill -TERM `cat /usr/local/apache/logs/httpd.pid`
235 For more information about Apache command line options, configuration
236 and log files, see <A HREF="invoking.html">Starting Apache</A>. For a
237 reference guide to all Apache directives supported by the distributed
238 modules, see the <A HREF="mod/directives.html">Apache directives</A>.
240 <H2>Compiling Support Programs</H2>
242 In addition to the main <CODE>httpd</CODE> server which is compiled
243 and configured as above, Apache includes a number of support programs.
244 These are not compiled by default. The support programs are in the
245 <CODE>support</CODE> directory of the distribution. To compile
246 the support programs, change into this directory and type
251 <!--#include virtual="footer.html" -->