Running a private copy of Apache 1.3 on Strauss
(STILL A WORK IN PROGRESS—NOT YET FULLY TESTED)

Running a private copy of Apache—or any copy of Apache!—is quite a bit more involved than running a copy of a simple web container such as Tomcat or Resin. The following is what I've been able to piece together so far from various documents.

Step 1 : Set an environment variable APACHE_HOME to point to the shared files

On strauss, the Apache software can be found in /usr/apache, so set an environment variable as follows:

 setenv APACHE_HOME /usr/apache 

Step 2 : Set an environment variable APACHE_BASE to point to your private files

Create an apache subdirectory under your home directory as follows

mkdir -p ${HOME}/apache

and point APACHE_BASE to this directory

setenv APACHE_HOME ${HOME}/apache

Note that unlike with Tomcat, where the software "knows about" HOME and BASE, that is not the case with Apache—we are defining those environment variable only for our own convenience. We have to hand code those locations in many places in the httpd.conf file (shown below).

Step 3: Copy the httpd.conf configuration files into your directory, and customize it.

You will need to create an httpd.conf file under $APACHE2_BASE, i.e. in your own personal space.

To start, copy the example file into your $APACHE2_BASE directory:

cp ~/CIS/software/apache2/conf/original/httpd.conf ${APACHE2_BASE}

Change the SERVER_ROOT

Find the ServerRoot and change this to be the location of your APACHE2_BASE. Note that as far as I know (and I could be wrong) you cannot use the Unix environment variable in this file. Apache has its own notion of environment variables, which differs from that of the Unix shell.

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation
# (available at <URL:http://www.apache.org/docs/mod/core.html#lockfile>);
# you will save yourself a lot of trouble.
#
ServerRoot "/home/usrk/f3/66143/apache"


The trouble with this is that it requires us to have all the modules under our directory as well. To get around, this, use a symbolic link:

ln -s /usr/apache/libexec/ ~/apache/libexec 
     
     

Comment out the "Listen 80" directive

You'll set the port number in a separate directory, so don't change the 80 to another number—just comment out the line.

Comment out the User and Group directives.

Since you aren't root, you don't have permission to change user or change group. So just comment these out.

  

Change the LockFile directive

It turns out that if you read that comment above, and follow the link to http://www.apache.org/docs/mod/core.html#lockfile you discover that while the other files (configuration, error, and log) can be placed on an NFS mounted directory (such as your home directory) with no trouble, the lockfile cannot be placed there.

Also, unfortunately, on strauss, as far as I know, the only non-NFS mounted directory to which normal users have permission to write is /var/tmp. This creates its own problems, as the apache documentation points out:

"It is best to avoid putting this file in a world writable directory such as /var/tmp because someone could create a denial of service attack and prevent the server from starting by creating a lockfile with the same name as the one the server will try to create."

However, unless someone can come up with a better solution, this is a vulnerability we have to live with. (In any case, if some malicious person does this to you, you can just change the name of your lockfile and get around the problem.)

So, make the following changes, substituting YOUR userid in place of jsample.

       # The LockFile directive sets the path to the lockfile used when Apache
       # is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or
       # USE_FLOCK_SERIALIZED_ACCEPT. This directive should normally be left at
       # its default value. The main reason for changing it is if the logs
       # directory is NFS mounted, since the lockfile MUST BE STORED ON A LOCAL
       # DISK. The PID of the main server process is automatically appended to
       # the filename. 
       #
       LockFile /var/tmp/jsample.httpd.lock
     

Change the PidFile directive

Also change the section that follows this (again, changing jsample to your userid).

       # PidFile: The file in which the server should record its process
       # identification number when it starts.
       #
       PidFile /var/tmp/jsample.httpd.pid
      


Change the ScoreBoard directive

Also change the section that follows this (again, changing jsample to your userid).

       # ScoreBoardFile: File used to store internal server process information.
       # Not all architectures require this. But if yours does (you'll know because
       # this file will be created when you run Apache) then you *must* ensure that
       # no two invocations of Apache share the same scoreboard file.
       #
       ScoreBoardFile /var/tmp/jsample.httpd.scoreboard
     

Change the Port directive

Change to a port that is free. To find a free port, use the netstat command, for example to see if port 2222 is free, type the following at the Unix command line:

netstat -an | grep 22222

After finding a free port, change port 80 to that port. To be safe, choose a port value between 10000 and 65535.

       # Port: The port to which the standalone server listens. For
       # ports < 1023, you will need httpd to be run as root initially.
       #
       Port 22222
 


Change the ServerAdmin

Change the ServerAdmin to your email address.

# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents.
#
ServerAdmin jsample@udel.edu

Change the Servername

Make the Servername strauss.udel.edu

Servername strauss.udel.edu

Change the DocumentRoot

Change this to the directory where your documents will be located. Note that you probably cannot use ~jsample for your home directory—instead, you should spell out the exact location on the disk (/home/usrk/f3/66143/apache/www/htdocs) not ~jsample/www/htdocs)

DocumentRoot "/home/usrk/f3/66143/apache/www/htdocs"

Also find the following, and change it to the same directory:

       # This should be changed to whatever you set DocumentRoot to.
       #
       <Directory "/home/usrk/f3/66143/apache/www/htdocs">
       
    

Change the ErrorLog directive

Change the ErrorLog to point to the "logs" directory under your APACHE_BASE

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog /home/usrk/f3/66143/apache/logs/error_log

You should also create this directory with:

 mkdir -p ${APACHE_BASE}/logs/error_log
       
     

Change the CustomLog directive

Change the CustomLog to point to the "logs" directory under your APACHE_BASE, and change the keyword common to combined.

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
CustomLog /home/usrk/f3/66143/apache/logs/access_log combined


Step 4: Check the syntax of the modified httpd.conf

To check the syntax, run the httpd server with the -f and -t flags as shown below. This will parse your httpd.conf file to check for syntax errors, without actually starting up the server:

  /usr/apache/bin/httpd -f ${APACHE_BASE}/httpd.conf -t

You should get output like the following:

> /usr/apache/bin/httpd -f ~/apache/httpd.conf -t
Syntax OK
> 

To start the server for real, just drop the -t flag

> /usr/apache/bin/httpd -f ~/apache/httpd.conf 
> 
    

To stop the server for real, use the kill command on the process id (which you can find in the /var/tmp/jsample.httpd.pid file, or by doing

ps -fu jsample

where jsample is your userid:

> kill 26539
> 
    


Valid XHTML 1.1 Valid CSS!