CSCI A348/A548

Lecture Notes 2

Fall 1999

We review the installation steps presented in the first lecture notes, with greater attention to details.

You may already have a web server, installed following the notes from the first lecture, with a welcome page and a simple, working, CGI script written in Perl. We have installed the web server, made the necessary changes to the configuration files and started the web server. Today we want to revisit installation and configuration of Apache because we want to change a few parameters, we want to look at one parameter that is very important in the Burrow setting, and we want to specify a few more configuration parameters (compared to the first lecture). In the process we clean up our disk space and keep only the relevant files and directories. We review the issues related to starting and stopping the server and introduce a way to start the server automatically (if necessary) to protect it from system reboots. This also counts as a Unix review.

1. Announcements

You are encouraged to work on assignments together, you'll get to know each other so that you can form project teams. Also make sure you know of and make good use of the newsgroup: ac.csci.a348

2. Installation of Apache

Apache should be installed in your directory and the relevant directory structure should be like this:

/u/username/httpd/                    # directory 
/u/username/httpd/httpd               # file 
                 /conf/               # directory
                 /conf/httpd.conf     # file 
                      /srm.conf       # file 
                      /access_conf    # file 
                 /htdocs/             # directory
                 /htdocs/index.html   # file 
                 /cgi-bin/            # directory 
                 /logs/               # directory
                 /logs/access_log     # file 
                 /logs/error_log      # file 
                 /logs/      # file 
Apache descends from NCSA and CERN so the structure is similar.

Here's a quick description of these files and directories.


This is the ServerRoot directory.
This file is the actual web server. You need to restart your server every time you make a change to one of your configuration files.
This directory contains configuration files.
This is the server's main configuration file.
This is the server resource configuration file.
This is the global access control file.
This is the DocumentRoot directory.
This is the server's welcome page.
This is the CGI scripts directory.
This directory contains log files.
The accesses to your site are logged here.
The server logs here any errors that hit has to report.
This file contains the process id of the server.
3. Configuration of Apache


In what follows please use your username instead of dgerman, your host name for tucotuco, and your port number for 19904. The file below is the one for the following assignment:

Your assignments should be different so please be aware of that. diff httpd.conf httpd.conf-dist
< Port 19904
> Port 80
< User dgerman
> User nobody
< ServerAdmin
> ServerAdmin you@your.address
< ServerRoot /u/dgerman/httpd  
> ServerRoot @@ServerRoot@@
< LockFile /tmp/apache.lockfile.dgerman
> #LockFile logs/accept.lock
< MinSpareServers 1  
< MaxSpareServers 3 
> MinSpareServers 5
> MaxSpareServers 10
< StartServers 1 
> StartServers 5 

So we change:


Please use your username instead of dgerman. diff srm.conf srm.conf-dist  
< DocumentRoot /u/dgerman/httpd/htdocs
> DocumentRoot @@ServerRoot@@/htdocs
< UserDir httpd/htdocs  
> UserDir public_html
< Alias /icons/ /u/dgerman/httpd/icons/
> Alias /icons/ @@ServerRoot@@/icons/
< ScriptAlias /cgi-bin/ /u/dgerman/httpd/cgi-bin/
> #ScriptAlias /cgi-bin/ @@ServerRoot@@/cgi-bin/ 
So we change:


Please use your username instead of dgerman. diff access.conf access.conf-dist
< <Directory /u/dgerman/httpd/htdocs>
> <Directory @@ServerRoot@@/htdocs>
< <Directory /u/dgerman/httpd/cgi-bin>
> <Directory @@ServerRoot@@/cgi-bin>
So we change two pathnames for:
4. Starting the server

If your server is not running already you need to login into your host and type the following command:

/u/username/httpd/httpd -d /u/username/httpd
where username is your username.

If your server is already running and if you're working on the host that you should be working on you won't be able to start the server with the command above. See restarting the server below.

To check if your server is running or not use:

/usr/bin/ps -ef | grep httpd | grep username
where username is your username. This should also return the server's pid.

5. Stopping the server

This can be done with:

kill -TERM `cat /u/username/httpd/logs/`
Make sure you notice the backquotes (`) above.

If the file does not exist you should find the pid of the server (as described before) and use

kill -TERM pid
where pid is the process id, that is, a(n up to 5-digit) number.

6. Restarting the server

kill -HUP `cat /u/username/httpd/logs/`
Same considerations apply.

8. Log files

Significant events, such as starting, stopping, restarting, and errors in general are recorded in

This file is useful for debugging CGI scripts and monitoring the server in general.

@@ServerRoot@@/logs/access.log contains a log of all calls to your server.

7. Protecting the server from machine reboots

Use starthttpd (written by Steve Kinzler) to start and stop the server.

Copy it into your bin directory:

cp /u/dgerman/bin/starthttpd /u/username/bin/starthttpd-template
cp /u/username/bin/starthttpd-template /u/username/bin/starthttpd
(Replace username with your username but do copy it from my account).

Then use the editor of your choice to change the script for your account such that the differences are like this: diff starthttpd starthttpd-template
<            # Server host
>            # Server host
< basecmd="/u/dgerman/httpd/httpd -d $httpd"
> basecmd="/u/username/httpd/httpd -d $httpd" 
Use crontab to schedule starthttpd. crontab -e crontab -l
0 6 * * * /u/dgerman/bin/starthttpd
This starts the server (if necessary) every day at 6am.

Last updated: September 2, 1999 by Adrian German