ICT336 title
Murdoch University logo

Laboratory Week 3 Part A - Configuring and Administering Apache


Learning Objective:

  1. Be familiar with some basic configuring and administering issues in Apache.

Required Reading:

Lectures: week 1 lecture 2 and week 2 lecture 1.
Unit Reader 1: Web Servers
Lab week 2

Access to Software:

In this lab, we will be using the machine gryphon.murdoch.edu.au, which is running Sun's Solaris operating system. We will access the machine via ssh and sftp sessions.

Students may use the puTTY program on Windows for a ssh session, and WinSCP for a sftp session. Internal students have access to the program in labs. External students may download the required software and install it on your own machine off campus. Internal students may do the same, but are encouraged to still attend labs for supervision when doing the exercises below.

Instructions:

For all instructions below, replace the number 12345678 with your own 8-digit student number, and the number 15678 with the port number allocated to you (more on this below).

In the examples, the words in teletype bold like this are commands you type in the ssh session. The words in teletype like this are what you see but and should not be typed in.

Starting your web server

Follow the instructions from week 2's lab to start your Apache web server.

Looking at the server's resource usage

While the server is running, you will be able to see the status of processes doing the job and how much resources they are using. Two ways of doing so is by the ps command, or the top command.

For example, to look at the processes involved in the web server you started up, you can type the command

ps -l -u 12345678

You will see something like the following:

 
 F S   UID   PID  PPID  C PRI NI     ADDR     SZ    WCHAN TTY      TIME CMD
 8 S 33701 14703     1  0  41 20        ?    305        ? ?        0:00 httpd
 8 S 33701 14704 14703  0  41 20        ?    338        ? ?        0:00 httpd
 8 S 33701 14705 14703  0  41 20        ?    305        ? ?        0:00 httpd
 8 S 33701 14706 14703  0  47 20        ?    305        ? ?        0:00 httpd
 8 S 33701 10193 10188  0  51 20        ?    353        ? pts/5    0:01 tcsh

The httpd with PID (process ID) of 14703 is the parent process, while the other 3 are the child processes waiting to serve requests. If the server has been running for a while, these child process IDs will change as they get killed off and new ones get started (see lecture notes on Apache's process model). Some useful fields to know for the "ps -l" display:

UID: user identification - every user has a number which is different from the username. Your username is of the form 12345678, but your UID is of the form 33xxx. You can find out your own UID by typing the "id" command on the command line.
PID: process identification - unique number for every process.
PPID: parent process ID - the parent process identification. In the example above, you can see that all child httpd processes are spawned by the parent process 14703.
CMD: command executed by the user.

To look at all web servers running on the machine, use the command:

ps -l -A | grep httpd

A better (but much more processor intensive) way of looking at the processes is by using the top command:

top

The top few lines of the results are the overall and available system resources and the summary usage by all processes. Below that is a display of the processes sorted by highest resource usage in real time. By default it refreshes every 5 seconds. If you access you web server to get a HTML file, you will see your own process pop up to near the top of the screen for a few seconds before going back to idle.

To quit the display, type "q".

A good way to monitor your web server resource usage is by typing "u" after starting top and then type in your user name (eg. s12345678). Then the display will be restricted to your processes only. To illustrate what the display can show you, bring up a web browser window but keep the top monitor on the screen at the same time. Now access a web page on your server (preferably one which you haven't accessed before) and you will see the CPU and memory usage of one of the child httpd processes increase.

Some useful fields to know for the top monitor screen (besides the fields already listed for ps above):

USER: username - yours is of the form 12345678.
SIZE: total memory used in kb - physical and virtual memory.
%CPU: estimated average percentage of total CPU used since the last screen update.
%MEM: estimated average percentage of total physical memory used since the last screen update.
TIME: total amount of CPU time used in hour:minutes format - for idle httpd processes, this will stay 0:00 until it gets requests.

USE THE top COMMAND SPARINGLY SINCE IT CHEWS UP A LOT OF MEMORY AND CPU TIME! If you start top and you see many others already have theirs started up, it may be a good idea to stop yours and try again later.

There is a lot more options to ps and top. Look up the manual entries for them by typing:

man ps
man top

Hint

Exercises:

  1. Start putting you own files into your installation's htdocs directory. Add sub-directories and put files in them as well. Access the files to make sure your server is doing its job properly. Understand the conversion rules your web server is using to convert between the URL string and the file system's pathnames.
    Those of you who have done B108 and B211 may put your whole project web-sites from those units in there. Note that some server-side scripts such as Perl/CGI or PHP will not work until you learn to configure your server to handle them.
  2. For internals students, find out the port number of someone next to you who is running his/her server, and access their web server and web site.
  3. Look at the access_log and error_log files in the logs directory of your installation. You can use the pico editor, or the less command to do so. Can you recognise the log entries corresponding to your accesses from the above exercises? Refer to the online manuals (especially the tutorials section) for more details of logging and the format of the log files.
  4. Using the Unix process monitoring mechanisms described in Instructions above, look at the changes in system resource usage for your server, as well as other servers. Change the process control directives in your httpd.conf file, and see how they affect the processes.
  5. Follow the instruction given in week 2 lectures to configure your web server to do the following:
    1. Turn on extended mod_status and view your web server usage and status using a web browser.
    2. Restrict access to a directory on your web site. Users should only be able to access the directory if they supply a username and password.
    3. Turn on server-side includes (SSI). Create a simple SSI file and see if your server can process and serve it properly.

 

Assessable Tasks:

Complete your Apache installation and basic configuration from week 2's lab and Exercise 1 above.

Internal students must demonstrate to your tutor a running server and your capability to access different files from your web-site using a browser. This must be done in week 3 or week 4. No marks will be awarded if the work is demonstrated after that - your tutor have no discretionary power on this deadline.

External students must submit the following:

 

Final Reminder:

Remember to stop your server before logging off!

H.L. Hiew
Unit Coordinator


Document author: H.L. Hiew, Unit Coordinator
Last Modified: Thursday, 19-Aug-2004 08:46:03 MST
Disclaimer & Copyright Notice © 2004 Murdoch University
This document is relevant for semester 1, 2004 only