Setting up your http server

Thanks to NCSA's documentation, the existence of precompiled binaries, and Managing Internet Information Services, NCSA httpd is fairly easy to set up for Linux. Once you've put the http kit in /usr/local/src, rename it httpd.tar.z with the mv command to save yourself some typing. Then open it up with zvat httpd.tar.Z | tar xvf - . You'll have a new directory, with lots of httpd files in it. For the sake of sanity, you'll probably want to copy this directory to /usr/local/etc/httpd. Next. you'll want to create and edit the httpd.conf, srm.conf, and access.conf configuration files in the conf directory. You can copy the -dist files provided with httpd, or you can work from mine. First, the httpd.conf file:
# This is the main server configuration file. It is best to 
# leave the directives in this file in the order they are in, or
# things may not go the way you'd like. See URL
# for instructions.
# Do NOT simply read the instructions in here without understanding
# what they do, if you are unsure consult the online docs. You have been
# warned.  
# NCSA httpd (comments, questions to
# ServerType is either inetd, or standalone.
ServerType standalone

# If you are running from inetd, go to "ServerAdmin".
# Port: The port the standalone listens to. For ports < 1023, you will
# need httpd to be run as root initially.
Port 80

# StartServers: The number of servers to launch at startup.  Must be
# compiled without the NO_PASS compile option
# StartServers 5
# MaxServers: The number of servers to launch until mimic'ing the 1.3
# scheme (new server for each connection).  These servers will stay around
# until the server is restarted.  They will be reused as needed, however.
# See the documentation on for more information.
# MaxServers 20
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
# User/Group: The name (or #number) of the user/group to run httpd as.
User http
Group WWW 

# ServerAdmin: Your address, where problems with the server should be
# e-mailed.

# ServerRoot: The directory the server's config, error, and log files
# are kept in
ServerRoot /usr/local/etc/httpd

# ErrorLog: The location of the error log file. If this does not start
# with /, ServerRoot is prepended to it.
ErrorLog logs/error_log

# TransferLog: The location of the transfer log file. If this does not
# start with /, ServerRoot is prepended to it.
TransferLog logs/access_log

# AgentLog: The location of the agent log file.  If this does not start
# with /, ServerRoot is prepended to it.
AgentLog logs/agent_log
# RefererLog: The location of the referer log file.  If this does not
# start with /, ServerRoot is prepended to it.
RefererLog logs/referer_log

# RefererIgnore: If you don't want to keep track of links from certain
# servers (like your own), place it here.  If you want to log them all,
# keep this line commented.
#RefererIgnore servername
# PidFile: The file the server should log its pid to
PidFile logs/

# ServerName allows you to set a host name which is sent back to clients for
# your server if it's different than the one the program would get (i.e. use
# "www" instead of the host's real name).
# Note: You cannot just invent host names and hope they work. The name you 
# define here must be a valid DNS name for your host. If you don't understand
# this, ask your network administrator.
Aside from the warnings (which are important), this file has a few pieces you should definitely customize or at least be aware of. Unless your Linux machine has lots of better things to do, I would ServerType as standalone. (The rest of this expects that you did.) You probably want to leave port as 80 - this is the default most programs will expect. If you have httpd running at startup, this should work fine. Otherwise, you'll always have to start it from the root account. Make sure you comment out StartServers and MaxServers - Linux doesn't seem to like them and gives out lots of error messages.

User and Group can be helpful if you want to make links to directories on other filesystems. Just make sure you create this user and group before running the server. Server admin is just your email address, nothing complicated. Server root is where the files will all be: I don't recommend changing this at all. The next set of preferences are for the logs - create a logs directory in your httpd directory. (You should also create an htdocs folder there as well.)

The next file you have to edit, access.conf, controls security for your web server. This isn't friendly stuff, but you shouldn't have to change very much of it, if any. You're the only here, and you're all-powerful, right? You may want to edit this if you have to deal with more complex configurations in the real world. Otherwise, leave this as is.

# access.conf: Global access configuration
# Online docs at
# I suggest you consult them; this is important and confusing stuff.
# /usr/local/etc/httpd/ should be changed to whatever you set ServerRoot to.

Options Indexes FollowSymLinks

# This should be changed to whatever you set DocumentRoot to.

# This may also be "None", "All", or any combination of "Indexes",
# "Includes", or "FollowSymLinks"
Options Indexes FollowSymLinks
# This controls which options the .htaccess files in directories can
# override. Can also be "None", or any combination of "Options", "FileInfo", 
# "AuthConfig", and "Limit"
AllowOverride None
# Controls who can get stuff from this server.

order allow,deny
allow from all

# You may place any other directories you wish to have access
# information for after this one.
The last file you have to work with is srm.conf. This gives you control over where html documents go, what kind of icons indexes will hold, and whether you want to use server features like server-side includes. For now, the main thing you want to make certain of is that the UserDir option is set to public_html. This lets any user on your system create a directory called public_html in their home directory for storing web documents, which is a real convenience. This is how it's frequently done on commercial servers, and lets you maintain multiple projects without making them interfere with each other. For instance, this web site is at on the PANIX server; on my Linux machine the same files are at It makes for a nice parallel.
# With this document, you define the name space that users see of your http
# server.
# See the tutorials at for
# more information.
# NCSA httpd (

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot /usr/local/etc/httpd/htdocs

# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is recieved.
UserDir public_html

# DirectoryIndex: Name of the file to use as a pre-written HTML
# directory index
DirectoryIndex index.html

# FancyIndexing is whether you want fancy directory indexing or standard
FancyIndexing on

# AddIcon tells the server which icon to show for different files or filename
# extensions
AddIconByType (TXT,/icons/text.xbm) text/*
AddIconByType (IMG,/icons/image.xbm) image/*
AddIconByType (SND,/icons/sound.xbm) audio/*
AddIcon /icons/movie.xbm .mpg .qt
AddIcon /icons/binary.xbm .bin
AddIcon /icons/back.xbm ..
AddIcon /icons/menu.xbm ^^DIRECTORY^^
AddIcon /icons/blank.xbm ^^BLANKICON^^

# DefaultIcon is which icon to show for files which do not have an icon
# explicitly set.
DefaultIcon /icons/unknown.xbm

# AddDescription allows you to place a short description after a file in
# server-generated indexes.
# Format: AddDescription "description" filename
# ReadmeName is the name of the README file the server will look for by
# default. Format: ReadmeName name
# The server will first look for name.html, include it if found, and it will
# then look for name and include it as plaintext if found.
# HeaderName is the name of a file which should be prepended to
# directory indexes. 
ReadmeName README
HeaderName HEADER

# IndexIgnore is a set of filenames which directory indexing should ignore
# Format: IndexIgnore name1 name2...
IndexIgnore */.??* *~ *# */HEADER* */README*

# AccessFileName: The name of the file to look for in each directory
# for access control information.
AccessFileName .htaccess

# DefaultType is the default MIME type for documents which the server
# cannot find the type of from filename extensions.
DefaultType text/plain

# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
# Format: AddType type/subtype ext1

# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
# information on the fly. Note: Not all browsers support this.
#AddEncoding x-compress Z
#AddEncoding x-gzip gz

# Redirect allows you to tell clients about documents which used to exist in
# your server's namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
# Format: Redirect fakename url

# Aliases: Add here as many aliases as you need, up to 20. The format is 
# Alias fakename realname
Alias /icons/ /usr/local/etc/httpd/icons/

# ScriptAlias: This controls which directories contain server scripts.
# Format: ScriptAlias fakename realname
ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-bin/

# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#AddType text/x-server-parsed-html .shtml
#AddType application/x-httpd-cgi .cgi

# If you want to have files/scripts sent instead of the built-in version
# in case of errors, uncomment the following lines and set them as you
# will.  Note: scripts must be able to be run as if the were called 
# directly (in ScriptAlias directory, for instance)

# 302 - REDIRECT 
# 400 - BAD_REQUEST 
# 403 - FORBIDDEN 
# 404 - NOT_FOUND 

#ErrorDocument 302 /cgi-bin/redirect.cgi
#ErrorDocument 500 /errors/server.html
#ErrorDocument 403 /errors/forbidden.html
Okay, you've waded through miles of configuration files, you're tired of waiting, and you have a major project due tomorrow. Let's fire this thing up!

It didn't come up my first time, or my second. Netscape didn't like something, so I wound up building the nameserver and taking a few detours. Nonetheless, if you've followed all of this, it should work. If you go back over this and it still doesn't work, email me. Let me know what Linux distribution you've got, what TCP stuff you've set up, and what client you're using. Maybe I'll be able to help you out, otherwise hit the bibliography and start reading or find a friendly system administrator or newsgroup to steer you through all of this.

For now, I'll assume this worked. There are a few things yet to do. First, let's hardwire the server so it's always available. To do this, edit your /etc/rc.d/rc.local file and add a line to run httpd. Here's mine:

#! /bin/sh
# Put any local setup commands in here

echo "Running httpd..."
Nothing special, but it does the job. Start your server up again and see if it works. That, at least, should work fine if you've followed all the instructions above.

If it works, get some champagne. Take a vacation someplace nice. Then come back and let's explore what you can do with this thing.

Back to the start of the Linux instructions

Copyright 1995 by Simon St.Laurent. All rights reserved. You may print this document for yourself or others at no charge, but commercial distribution without permission is prohibited.

448 West 25th Street #3
New York, NY 10001