Goal:
- Learn
how to configure apache as
- web
server.
- cache server
- reverseproxy
- Learn
how to form a single cluster using reverseproxy.
- Learn
how to use ab to evaluate the web server performance.
Assignment
Date: 2/11/2009
Due Day: 2/18/2009
Related documents:
Description:
Part 1. Configure
apache to run as a web server
- In this exercise,
we will learn how to configure apache httpd to run as a web server.
- In the following description, we assume jlogan is your account; the last three digits of your SID is 345; you are using blanca for this exercise. Modify the scripts/configuration accordingly by replacing your account name and related info.
- We will carry out this exrecise on CS Unix machines (windom, blanca, or shavano, but not on cs). If you find they are busy or not responding, you can choose to run your exercises on viva. However the prefix of the full file path will change from /users/server/students to /home
- In /users/server/students/cs526/public_html/httpd/httpd-2.2.11 we have compiled the apache httpd version 2.2.11 with basic cache and proxy modules. There
is a httpd program in bin directory and the modules is in modules directory. This is the Apache HyperText Transfer Protocol
(HTTP) server program. It is designed to be run as a standalone daemon process.
- Read man page with "man httpd" for more info. The related http-2.2 version documents are available at http://httpd.apache.org/docs/2.2
SYNOPSIS
httpd [ -X ] [ -R libexecdir ] [ -d serverroot ] [ -f con-fig ] [ -C directive
] [ -c directive ] [ -D parameter ]
- If "/usr/sbin/httpd -d /users/server/students/cs526/public_html/apache/ws1
-X" is run, the httpd program will treat /users/server/students/cs526/public_html/apache/ws1
as serverroot directory and read the directives in the conf/httpd.conf file
for configuring the apache server. -X is for debugging purpose, it indicates
to the httpd daemon that do not fork spare child process for improving performance.
Just run a single standalone process.
- The Apache provides a rich set
of directives for configuring/customizing the web server. A subset of directives
are realized by an Apache module. See http://httpd.apache.org/docs/2.2/mod/directives.html for the set of runtime directives.
- An example of httpd.conf is
LoadModule log_config_module
/etc/httpd/modules/mod_log_config.so
LoadModule access_module /etc/httpd/modules/mod_access.so
User
jlogan
ServerName blanca.uccs.edu
Listen 8388
DocumentRoot
/users/server/students/jlogan/public_html/apache/ws1/htdocs
ErrorLog
logs/error_log
TransferLog logs/access_log
PidFile logs/httpd.pid
- The first directive LoadModule
tells the httpd program to dynamically load in /etc/httpd/modules/mod_log_config.so as dynamic shared object (very much like dll). The log_module code deals
with creating error log entries in the log files.
- Access_module deals with creating
access log entries in the log files.
- User directives tells httpd to
run itself as jlogan account.
- ServerName tells httpd the domain
to use when displaying error msg.
- Listen directive tells httpd to listen
to port 8388 for incoming http requests. We need to enter http://blanca.ccs.edu:8388/
to access this webserver.
- DocumentRoot specifies the actual
path to the default web document directory.
- ErrorLog specifies the name of the
file for saving error log records.
- TransferLog specifies the name
of the file for saving the access records.
- PidFile specifies the names fo
the files for saving the process id of the httpd server. It can be used
by system admin to restart or stop the httpd server. Note that the CS Unix machines are currently running httpd 2.2.3 (/usr/sbin/httpd) and the modules are located in /etc/httpd/module.
You can try to run "telnet cs.uccs.edu 80" and type "GET / HTTP/1.0 <enter><enter>" to find out the server version:
[cs526@blanca ~]$ telnet cs.uccs.edu 80
Trying 128.198.162.68...
Connected to cs.uccs.edu (128.198.162.68).
Escape character is '^]'.
GET / HTTP/1.0
HTTP/1.1 200 OK
Date: Mon, 09 Feb 2009 23:45:12 GMT
Server: Apache/2.2.3 (CentOS)
- In httpd version 2.2.0, the User, ServerName, ErrorLog are in "core" or mpm (multi-process module)" basic modules which constitute the basic httpd program. There are no need to use LoadModule directive
Part1. Exercise1: Configure a simple apache server (ws1)
- Login to blanca.
- Copy the directory ~cs526/public_html/apache to your ~<login>/public_html/cs526
directory, using "cp -r ~cs526/public_html/apache ~<login>/public_html/cs526.
- cd public_html/cs526/apache/ws1/conf
- edit httpd.conf file by replacing
all LOGIN instances with your own login name on CS Unix machines. In other
words,
- Replace parameter of the User directive
with your own account.
- Replace parameter of DocumentRoot and point
to your own htdocs directory.
- Replace the port number with 8<last
3 digits of your SID> in the Listen directive. Say from 8822 to 8345 assume 345 are the last 3 digits of your SID.
- Make sure you have mime.types in your conf directory (new apache2 requirement).
- "cd ../htdocs" to web
server default document directory.
- Edit the index.html in htdocs directory
to include "created by <login> on blanca" where <login> is your login name.
- Edit the cmd file substitute the
"LOGIN/public_htlm" string there with "<your loginname>/public_html".
- Run the apache web server with
"./cmd &"
which is equivalent to run
"/users/server/students/cs526/public_html/httpd/httpd-2.2.11/bin/httpd -d /users/server/students/LOGIN/public_html/cs526/apache/ws1
-X & "
- Go to any browser and enter "http://blanca.uccs.edu:8<last
3 digits of your SID>", e.g., http://blanca.uccs.edu:8345/, and see if the web page shows
up.
- Check the logs in /users/server/students/<yourloginname>/public_html/apache2/ws1/logs/access_log
and see the access records is created. You can also type the url http://cs.uccs.edu/~cs591/apache/ws1/logs/access_log, assume cs591 is your login.
Part1. Exercise2: Setup web server 2 on shavano
- Login to shavano.
- cd public_html/apache/cs526/ws2
- Repeat the above steps for shavano
web site.
- "cd ../htdocs" to web
server default document directory.
- Edit the index.html in htdocs directory
to include "created by <login>" where <login> is your login name.
- Edit the cmd file substitute the
"LOGIN/public_html" string there with "<your loginname>/public_html".
- Run the apache web server with
"./cmd &"
which is
"/users/server/students/cs526/public_html/httpd/httpd-2.2.11/bin/httpd -d /users/server/students/<your
loginname>/public_html/cs526/apache/ws2 -X"
- Test it with http://windom.uccs.edu:8345/
Part1. Exercise3: Setup web server 3 on windom
- login to windom.
- cp -r ws1 ws3 to create ws3 directory.
Repeat the above steps for shavano
web site.
- Edit the httpd.conf
file and web page files in ws3/conf/htdocs directory to reflect the machine
windom which will serve the web page.
- Under htdoc directory, create a subdirectory personnel and
a personnel web page with "this is windom personnel web page "
as content in the htdocs directory.
- Run the web server. See if you can access the personnel web page, and leave some
access records.
Create a homework web page hw2.html
in your cs526 personal web page directory