Notes for Week 2

  1. On our systems, the following commands will install Apache:
    mount -wo remount /
    cd /usr/src
    tar -xjf httpd-2.2.2.tar.bz2
    cd httpd-2.2.2
    
    groupadd -g 25 apache
    useradd -c "Apache Server" -d /dev/null -g apache -s /bin/false -u 25 apache
    
    (patch -Np1 -i ../httpd-2.2.2-config-1.patch) 2>&1 | tee -a ../apache.out
    
    (./configure --enable-layout=FHS --enable-mods-shared=all --with-expat=/usr --enable-ssl --with-pcre --with-z) 2>&1 | tee -a ../apache.out
    
    (make) 2>&1 | tee -a ../apache.out
    
    (make install) 2>&1 | tee -a ../apache.out
    
    chown -v root:root /usr/lib/apache/httpd.exp \
        /usr/sbin/{apxs,apachectl,dbmmanage,envvars{,-std}} \
        /usr/share/man/man1/{dbmmanage,ht{dbm,digest,passwd}}.1 \
        /usr/share/man/man8/{ab,apachectl,apxs,htcacheclean,httpd}.8 \
        /usr/share/man/man8/{logresolve,rotatelogs,suexec}.8 &&
    chown -v -R apache:apache /srv/www
    
    sed -i -e "s/User daemon/User apache/" -e "s/Group daemon/Group apache/" /etc/apache/httpd.conf
    
    cd /sources/blfs-bootscripts-20060624/
    make install-apache
    cd
    
    mount -ro remount /
    
    The mount commands are necessary because our systems run with a read-only root filesystem (which is where we will be installing Apache). The build takes place in /usr/src/httpd-2.2.2 (the Apache source tree after it is uncompressed by tar), and the install is to directories in the /usr directory tree.

    This configuration is based on Beyond Linux From Scratch 6.2, and causes Apache to run its slave processes under the unprivileged user "apache". The "expat", "ssl", "pcre" and "z" parameters to configure tells Apache to use the versions which are already installed. The file /etc/rc.d/init.d/apache is the script used to start and stop Apache.

  2. EXERCISES for Week 2:

    1. Start Apache using the command "/etc/rc.d/init.d/apache start". Observe from "ps aux" output that the actual server program is httpd: the HyperText Transfer Protocol Daemon. Note that the master process runs as root; it directs client requests to the slave processes. Test Apache by entering "127.0.0.1" as the URL in mozilla.
    2. The document root for your server is /srv/www/htdocs. Create a home page for your server to replace the current index.html file. Reload the URL 127.0.0.1 to test your new home page.
    3. Using the information in last week's notes, add a firewall rule to permit access to your web server from other PCs in the lab. Re-run your firewall script and test access to your server from other stations.
    4. Stop Apache using the command "/etc/rc.d/init.d/apache stop". Examine the files in /var/log/apache.

      The access_log file contains the following information for every file served to a client:

      • the client IP address
      • the date and time of the request
      • the method (typically GET or POST)
      • the file name requested by the client
      • the HTTP version used by the client
      • the result code for the request
      • the number of bytes in the file


©2006, Kenneth R. Koehler. All Rights Reserved. This document may be freely reproduced provided that this copyright notice is included.

Please send comments or suggestions to the author.