Previous | Top | Next | Search | Comments

Client/Server Computing

APACHE

This section describes how to bring up an Apache HTTP server.

According to Netcraft, Apache has been the most popular HTTP server for quite some time. This is understandable since it, like the other servers described here, is "as free as a free kitten", runs under any flavor of Unix, is very extensible, and is just about as robust a server you will find anywhere. As of version 1.3b, Apache now also runs under Windows95 and NT. It will also be ported to Rhapsody (Macintosh) when that operating system becomes available this year. Consequently, Apache represents a good, all-around HTTP server. One that you can/will be able to take to just about any computer.

Apache, based on the original NCSA httpd application, got its name from when its developers where trying to break httpd down into its original parts. Thus, it was "a patchy server."

There are two alternatives for acquiring the Apache software. One, you can download a precompiled binary for your particular version of Unix or Windows. Or two, you can download Apache's source code and compile it yourself. This section outlines the second option for Unix since it offers you greater flexibility.

COMPILING

Compiling our own version of Apache is a 4-step process:

  1. downloading the archive and uncompressing it
  2. editing the src/Configuration file
  3. running src/Configure
  4. running make

Begin by downloading the archive from www.apache.org. If you are adventurous, then download the latest beta version. Otherwise grab the version without any b's listed in its name. (Notice how small the archives are. They could easily fit on a single floppy disk!)

Next, uncompress and untar the downloaded file with gunzip and tar. This should result in a directory named apache_1.2.5 or something similar.

Change directories to the src directory within the apache_1.2.5 directory. Use your favorite text editor to edit the file named Configuration. The Configuration file lists the modules ("patches") you would like to incorporate into your httpd binary. All of these modules are described in the online documentation. Consider uncommenting the module named status_module. This module will allow you to monitor the status of your server from a WWW browser. To uncomment a module remove the pound sign (#) preceeding its definition.

Next, enter the Configure command. This command very quickly edits a few files in your distribution and returns. Now, enter make and wait. If everything goes well, you should see a lot of text scrolling up your terminal but finally you will get your prompt back and your Apache HTTP server is compiled.

CONFIGURATION

Configuring the Apache server requires the following steps:

  1. copying the compiled binary up one directory level
  2. editing conf/httpd.conf
  3. editing conf/srm.conf
  4. editing conf/access.conf

Copy your newly created Apache server application up one directory out of the src directory. To make your life easier, this directory should also contain the htdocs, logs, conf, and cgi-bin directories.

Change to the conf directory and cp httpd.conf-dist httpd.conf. This will make sure you have an original version of the httpd.conf file. Using your text editor again, edit httpd.conf. In this file you will want to change the following definitions:

Port
Enter an integer. The default port of HTTP servers is 80. If you are the superuser of your Unix computer, then you will be able to run the server on this port. If you are just exerimenting, then use a port like 8000. Example: 8000
User
Enter a username. The user variable is used to tell the server who owns the httpd process once it it running. Since the httpd application will have to read and write files on your computer, it will be necessary to select a username that has just the right number of priveleges. It is best to create a bogus user named "nobody", give them few priveleges, and have the httpd application run under that user. Example: nobody
Group
Enter an integer. Every username should be assigned to at least one usergroup. Like usernames, groups help define priveleges on the computer and you should have a group defined that has limited authority. Enter a pound sign followed by an integer denoting the group the httpd application should run under. Example: #-1
ServerAdmin
Enter here the email address of the person who should get messages when things go wrong. (Obviously this will never be needed.) Example: webmaster@lib.univ.edu
ServerRoot
Enter the full path to the httpd application. Example: /usr/local/apache
ServerName
Enter here the IP address or fully qualified domain name of your Unix computer. This address or name will be the name returned to any clients connecting to your server. Do not make up a name. Example: dewey.lib.univ.edu

Next, cp srm.conf-dist srm.conf so you have a backup of the file. Here you will want to make sure you edit the following values:

DocumentRoot
Enter the full path to the location where you will be saving your HTML documents. Example: /usr/local/apache/htdocs
ScriptAlias
If you plan on using CGI scripts, then you will want to change this configuration to map a virtual directory to a real directory containing the scripts. Example: /cgi-bin/ /usr/local/apache/cgi-bin/
AddHandler
Again, if you want to run CGI scripts from your server, it is convienent to create a filetype here with the .cgi extension. Example: cgi-script .cgi

You are more than half way there. Keep editing!

The final configuration requires you to edit access.conf. First cp access.conf-dist access.conf.

The access.conf file is made up of <Directory></Directory> pairs. By default the file defines access configurations for your HTML document root and your cgi-bin directory. You will want to change the values already in the file to the same values you specified for the DocumentRoot and ScriptAlias above. Examples: <Directory /usr/local/apache/htdocs> and <Directory /usr/local/apache/cgi-bin>.

If you compiled your httpd binary with status_module, then uncomment all the lines in the <Location /server-status> directive and edit the allow from line to include your domain. If you do this, then once your server is running you will be able to enter a URL like http://www.lib.univ.edu/server-status and see how your server is running.

WINDOWS
CONFIGURATION

Installing and configuring the Windows95/NT version of Apache includes two options. First, you can download the source code and compile it. This requires a Microsoft C++ compiler. Alternatively, you can download a pre-compiled version of the application. If you own the compiler, then you don't need any instructions. Otherwise, download the pre-compiled version.

Whether you have downloaded the source code or the pre-compiled version, you will want to edit the *.conf files just as above.

STARTING UP

It is now time to actually start up your server. Move up one directory and run the httpd application with ./httpd -f path, where path is the fullpath name to your httpd.conf file. For examaple, httpd -f /usr/local/apache/conf/httpd.conf. (If you are running the Windows version, then you will want to run the application from the command line and specify the fullpath of the httpd.conf file as an argument: c:\apache\apache.exe -f c:\apache\conf\httpd.conf.) If an error is returned, then read it carefully and try to resolve the problem. If no errors occured, then use your browser to open a connection to your server. Remember to specify the Port in your URL as you defined above. If for some reason you do not get the "It worked!" message, then check the contents for your logs/error_log file for clues to what went wrong.

At this point your are either overjoyed or overwhelmed. Those of you who are overjoyed should now go back to your configurations to make more specific modifications. Those of you who are overwhelmed are encouraged to visit news:comp.infosystems.www.servers.unix and try to get some assistance there. Carefully worded questions will get responses.


Previous | Top | Next | Search | Comments

Version: 1.5
Last updated: 2004/12/23. See the release notes.
Author: Eric Lease Morgan (eric_morgan@infomotions.com)
URL: http://infomotions.com/musings/waves/