276 lines
8.9 KiB
HTML
276 lines
8.9 KiB
HTML
<html>
|
|
<head>
|
|
<title>Setting Up the Apache Web Server Under Linux</title>
|
|
</head>
|
|
<body>
|
|
|
|
<H4>
|
|
"Linux Gazette...<I>making Linux just a little more fun!</I>
|
|
"</H4>
|
|
|
|
<P> <HR> <P>
|
|
<!--===================================================================-->
|
|
<h1 align=center>Setting Up the Apache Web Server Under Linux </h1>
|
|
|
|
<center><H4>by Andy Kahn,
|
|
<a href="mailto:kahn@cs.ucla.edu"> kahn@cs.ucla.edu </a>
|
|
</center>
|
|
|
|
<p>
|
|
<hr></p>
|
|
|
|
<p>This article is basically a summary of my experiences of setting up
|
|
a web server under Linux. I will start with where/how to obtain Apache,
|
|
then move on to installation, configuration, and finally how to get things
|
|
running. This article is written from the point of view of my system, which
|
|
is a Red Hat 4.0 system with v2.0.25 of the kernel. However, a "generic"
|
|
installation or a similar setup should apply as well. </p>
|
|
|
|
<ul>
|
|
<li><a href="#WHERE">Where To Get Apache</li></a>
|
|
<li><a href="#INSTALL">Installation</li></a>
|
|
<li><a href="#CONFIG">Configuration</li></a>
|
|
<li><a href="#START">Starting/Running the Web Server</li></a>
|
|
<li><a href="#FUTURE">What's Next</li></a>
|
|
</ul>
|
|
|
|
<p>
|
|
<hr></p>
|
|
|
|
<h3><a name="WHERE">Where To Get Apache </h3></a>
|
|
|
|
<p>The obvious place to get the latest version of Apache is off of the
|
|
Apache web site: <a href="http://www.apache.org">http://www.apache.org</a>.
|
|
The source distribution file is <i><a href="http://www.apache.org/dist/apache_1.1.1.tar.gz">apache_1.1.1.tar.gz</a></i>
|
|
while the Linux ELF binaries is <i><a href="http://www.apache.org/dist/binaries/linux/apache_1.1-linux-ELF.tar.gz">apache_1.1-linux-ELF.tar.gz</a></i>.
|
|
Grab what you find is necessary... </p>
|
|
|
|
<p>If you are running Red Hat Linux 4.0 like I am, during the installation
|
|
process you are allowed to select whether or not you want to install a
|
|
web server. If you do, Red Hat 4.0 includes the latest Apache and installs
|
|
everything automatically with a default configuration. This default configuration
|
|
even <b>RUNS</b> correctly without any modifications! However, even in
|
|
this case, please read my notes and preferences regarding installation
|
|
in the next section. </p>
|
|
|
|
<p>Typically, unless you need to add special modules or features, the binary
|
|
distribution or the default Red Hat installation should be fine. However,
|
|
let's say you wanted to run Apache as a proxy server. In this case, you
|
|
would need the source so you can compile the proxy module as part of the
|
|
binary. </p>
|
|
|
|
<p>(Note: I have heard rumors that the binary included with Red Hat 4.0
|
|
has some bugs. I have yet to encounter any myself, so take that rumor with
|
|
a <b>big</b> grain of salt.) </p>
|
|
|
|
<p>
|
|
<hr></p>
|
|
|
|
<h3><a name="INSTALL">Installation </h3></a>
|
|
|
|
<p>I'm not going to cover compiling Apache since it's actually a fairly
|
|
painless process and pretty well documented. Given that, let's move on
|
|
to actual installation... </p>
|
|
|
|
<p>Personally, I like to group all the web server files together in a centralized
|
|
location. If you are installing this manually, then this is something you
|
|
can do from the outset, and I highly suggest doing this since it will reduce
|
|
administration headaches. </p>
|
|
|
|
<p>If you had Apache installed automatically as part of the Red Hat installation
|
|
procedure, then things will NOT be centralized! In fact, I thought the
|
|
file placement scheme was one of the most confusing I've ever encountered.
|
|
Here's what the Red Hat installation does: </p>
|
|
|
|
<table border>
|
|
<tr>
|
|
<td valign="top">web server binaries </td>
|
|
|
|
<td>/usr/sbin/httpd<br>
|
|
/usr/sbin/httpd_monitor </td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>config files </td>
|
|
|
|
<td>/etc/httpd/conf/* </td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>log files </td>
|
|
|
|
<td>/etc/httpd/logs/* </td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">web server root<br>
|
|
(contains cgi, icons/images, and html files) </td>
|
|
|
|
<td valign="top">/home/httpd/* </td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>I found this to be really disorganized, so I ended up putting mostly
|
|
everything under one directory (I left the binaries in /usr/sbin): </p>
|
|
|
|
<pre> mkdir /httpd
|
|
mv /etc/httpd/conf /etc/httpd/logs /home/httpd/* /httpd
|
|
rmdir /home/httpd
|
|
</pre>
|
|
|
|
<p>You should end up with: </p>
|
|
|
|
<pre> /httpd/
|
|
/cgi-bin
|
|
/cgi-src
|
|
/conf
|
|
/html
|
|
/icons
|
|
/logs
|
|
</pre>
|
|
|
|
<p>And then to preserve the original Redhat file locations: </p>
|
|
|
|
<pre> ln -s /httpd /home/httpd
|
|
ln -s /httpd/conf /etc/httpd/conf
|
|
ln -s /httpd/logs /etc/httpd/logs
|
|
</pre>
|
|
|
|
<p>Finally, I added this link since I felt that it made more sense: </p>
|
|
|
|
<pre> ln -s /httpd/logs /var/log/httpd
|
|
</pre>
|
|
|
|
<p>If you are installing and compiling Apache manually, you may want to
|
|
have the original source files also located under /httpd (or whichever
|
|
directory you have). </p>
|
|
|
|
<p>
|
|
<hr></p>
|
|
|
|
<h3><a name="CONFIG">Configuration </h3></a>
|
|
|
|
<p>Apache has three main configuration files: <b><i>access.conf</i></b>,
|
|
<b><i>httpd.conf</i></b>, and <b><i>srm.conf</i></b>. If you are running
|
|
Red Hat 4.0, these files will already be set with the correct directory
|
|
paths. If you centralized the locations of all these files, but made those
|
|
symbolic links as I mentioned above, things will still be fine since the
|
|
symbolic links preserves where Red Hat installed everything. </p>
|
|
|
|
<p>If you are doing a "generic" installation or have some other
|
|
setup, then you will need to do the following: </p>
|
|
|
|
<p>In <b><i>access.conf</i></b>, change/update these directory entries:
|
|
</p>
|
|
|
|
<pre> <Directory /httpd/html>
|
|
<Directory /httpd/cgi-bin>
|
|
</pre>
|
|
|
|
<p>In <b><i>httpd.conf</i></b>: </p>
|
|
|
|
<pre> ServerRoot /httpd
|
|
</pre>
|
|
|
|
<p>In <b><i>srm.conf</i></b>: </p>
|
|
|
|
<pre> DocumentRoot /httpd/html
|
|
Alias /icons/ /httpd/icons/
|
|
ScriptAlias /cgi-bin/ /httpd/cgi-bin/
|
|
</pre>
|
|
|
|
<p>Essentially, these are the necessary directives in the config files that
|
|
need to be updated with the new "centralized" organization. </p>
|
|
|
|
<p>For further configuration options, I will have to give the standard
|
|
statement, "Please refer to the docs." :) </p>
|
|
|
|
<p>
|
|
<hr></p>
|
|
|
|
<h3><a name="START">Starting/Running the Web Server </h3></a>
|
|
|
|
<p>To make a long story short, you simply to need to execute the binary
|
|
"httpd". Typically, this is done when the system starts up, in
|
|
one of the rc files. </p>
|
|
|
|
<p>In Red Hat 4.0, it has more of a System V'ish startup style. In
|
|
<b><i>/etc/rc.d/init.d</i></b>
|
|
resides <b><i>httpd.init</i></b>, which is the script used
|
|
to start and stop httpd.
|
|
You can also execute this by hand if you find the need. </p>
|
|
|
|
<p>For other systems (or a manual install), I suggest starting httpd after
|
|
most other services have started (i.e.: put it in <b><i>rc.local</i></b>).
|
|
A simple line such as </p>
|
|
|
|
<pre> /usr/sbin/httpd &
|
|
</pre>
|
|
|
|
<p>will suffice. </p>
|
|
|
|
<p>Obviously, it must start after tcp/ip networking has been started. :)
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="FUTURE">What's Next</h3></a>
|
|
|
|
<p>
|
|
Needless to say, I didn't cover actual configuration options
|
|
and how to manage your web server. The configuration options
|
|
I leave to the Apache manual. Managing the web server itself
|
|
depends on what kind of web site you want to run. My own system
|
|
does not run a "real" web site; in other words, I don't advertise
|
|
it for anything because it serves no real purpose other than for
|
|
my own experimentation. However, you are more than welcome to
|
|
take a look at it since it does have a bunch of Linux related
|
|
links to it. The URL can be found at the end of this article.
|
|
</p>
|
|
<p>
|
|
Other than that, I would love to hear any comments and/or
|
|
criticisms you may have about what I wrote. Originally, my
|
|
plan was to write a monthly article about running/managing a
|
|
web server under Linux. However, short of actually writing a
|
|
manual on configuring Apache (which the Apache documentation
|
|
is good enough as a reference), I don't know what else to
|
|
write about since there may not be all that much to write
|
|
about.
|
|
</p>
|
|
<p>
|
|
However, one idea for a monthly thing that might be good is
|
|
to collect hints, tricks, and other useful information related
|
|
to running a web server under Linux. Think of it more as a
|
|
"2 cent tips for a linux web server." If anyone is interested
|
|
in this, please drop me a note!
|
|
</p>
|
|
|
|
<ul>
|
|
<li>Email: <a href="mailto:kahn@cs.ucla.edu">kahn@cs.ucla.edu</a>
|
|
<li>Home page: <a href="http://www.cs.ucla.edu/~kahn">
|
|
http://www.cs.ucla.edu/~kahn</a>
|
|
<li>His machine: <a href="http://vivian.cs.ucla.edu">
|
|
http://vivian.cs.ucla.edu</a>
|
|
</ul>
|
|
</p>
|
|
|
|
<!--===================================================================-->
|
|
<P> <hr> <P>
|
|
<center><H5>Copyright © 1996, Andy Kahn <BR>
|
|
Published in Issue 12 of the Linux Gazette</H5></center>
|
|
|
|
<!--===================================================================-->
|
|
<P> <hr> <P>
|
|
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
|
|
ALT="[ TABLE OF CONTENTS ]"></A>
|
|
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
|
|
ALT="[ FRONT PAGE ]"></A>
|
|
<A HREF="./expo.html"><IMG SRC="../gx/back2.gif"
|
|
ALT=" Back "></A>
|
|
<A HREF="wkndmech.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
|
|
<P> <hr> <P>
|
|
</BODY>
|
|
</body>
|
|
</html>
|
|
|