Goal:
- Learn
how to configure apache as
- Learn
how to use ab to evaluate the web server performance.
Assignment
Date: 1/30/2012
Due Day: 2/8/2012
Related documents:
Description:
Logistics:
- I have created your account on gandalf, viva, walrus, wins.csnet, and sam.csnet for this exercise and next on to form a cluster. I also copy the apache directory and setup.pl from ~chow/public_html/cs526 to your cs526 directory. If you garbled the content, feel free to download it again.
Machine Name |
Machine Type |
Procssor spec |
Main Memory |
Network Speed |
OS |
Web sites to run |
viva |
optiplex 620 |
duo core 3.2GHz |
4GB |
1Gbps |
Fedora Core 16 |
ws1 |
walrus |
optiplex 960 |
quad core
Q9550 2.83GHz |
8GB |
1Gbps |
Fedora Core 16 |
ws2/caching |
wins.csnet |
VM; host is willow.uccs.edu
optiplex 990 Win7 |
vCPU with VBOX on Core i7
3.4 GHz |
1GB |
1Gbps |
Fedora core 16 |
ws3 |
gandalf |
optiplex 960 |
quad core
Q9550 2.83GHz |
8GB |
1Gbps |
Fedora Core 16 |
testing |
willow |
optiplex 990 |
i7
Q9550 2.83GHz |
8GB |
1Gbps |
Win7 |
IIS7 |
sam.csnet |
vm on Dell server in EAS Cluster |
Nehalem Gen. Xeon Core i7 core 2.66GHz
|
1GB |
1Gbps |
Fedora Core 16 |
ws4/reverseproxy |
- Under apache directory there are five root directories (ws1, ws2, ws3, proxy, reverseproxy) for the five server configurations.
- To reduce your work:-) and avoid typing mistakes, I create a set up script setup.pl for change the apache server configuration to reflect your login and use 8 or 9 followed by the last 3 digits of your SID as port number. Just run "./setup.pl <yourlogin> <last3DigitsSID>" in cs526 directory to configure those sites.
- For James Logan with jlogan as login and 345 as last three digits of SID, run "./setup.pl jlogan 345".
- Note that these five machines do not share NFS for a common home directory.
- Since we are measuring the web server performance and do not want NFS acccess across network as a bottlenck.
- You will have to run the setup.pl on each machine to configure the apache site.
- I do rsync between walrus (master) and gandalf (slave) now. What will be the problem?
- If you gobble your apache directory, you can copy a fresh copy from that of chow with "cp -r ~chow/public_html/cs526/apache ."
- Use the cmd command to run the server. It will be idle there waiting to processing the requests. You use "./cmd &" to put it in background and use fg to bring back.
- Make sure your kill the process after your exercise.
- The process id of web server will be saved by httpd in logs/httpd.pid.
- You can also use ps aux | grep <login> to find out the process id.
- Or you can use "lsof -i :8<last3DigitsSID>" to find out the process id.
- Use "kill -TERM <pid>" to kill the process.
- You can also use control-c or kill -9 <pid> to kill the httpd parent process. What are the differences?
See the Q&A explanation at the buttom of the web page.
- Use "kill -TERM <pid>" or "kill -15 <pid>" to inform httpd parent process to immediately attempt to kill off all of its chidren then exit.
- There is a more gentle termination called "Graceful Stop" which allows children to exit after their current request is done (exit if idle). "kill -WINCH <pid>". It may take a while before you can run cmd again. It may report the "socket adres already in use."
- For graceful restart (after apache update or configuration setting changes), use "kill -USR1 <pid>"
- See more details in "apache stopping/restarting" and UNIX signal we page.
- After your exercise, please run the ipcs -s to see the semaphore arrays created. Too many of them not release will hang the system.
Make sure you use " ipcs -s | grep `whoami` | perl -e 'while (<STDIN>) {@a=split(/\s+/); print `ipcrm sem $a[1]`}'
to remove the semaphores created by you. - We will reboot the systems 3am to clean out dangling zambies. But let me know if the system is very slow. Could be caused by a lot users running.
- Change the program of the cmd shell script in each of the directory to /home/cs526/public_html/httpd/httpd-2.2.21/bin/httpd (from 2.2.17 or 2.2.21)
- Make sure you check the parameters modified by the setup.pl. No perfect code here. From time to time, I still find bugs on my scripts:-)
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.
- 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 "/home/cs526/public_html/httpd/httpd-2.2.21/bin/httpd -d /home/cs526/public_html/cs526/apache/ws1
-X" is run, the httpd program will treat /home/cs526/public_html/cs526/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 or create threads 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 walrus.uccs.edu
Listen 8345
DocumentRoot
/home/jlogan/public_html/cs526/apache/ws1/htdocs
ErrorLog
logs/error_log
TransferLog logs/access_log
PidFile logs/httpd.pid
- Note that in your ws1/conf/htttpd.conf, there are no LoadModule directives. The reason is that the
/home/cs526/public_html/httpd/httpd-2.2.21/bin/httpd
we use is compiled with access and log_conifig module compiled in (built-in).
See the extensive examples in /etc/httpd/conf/httpd.conf starting line 149.
- 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 8345 for incoming http requests. We need to enter http://walrus.uccs.edu:8345/
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 CSNET Unix machines are currently running httpd 2.2.21 (/usr/sbin/httpd) and the modules are located in /etc/httpd/module.
You can try to run "telnet walrus.uccs.edu 80" and type "GET / HTTP/1.0 <enter><enter>" to find out the server version:
[root@gandalf htdocs]# telnet walrus.uccs.edu 80
Trying 128.198.60.197...
Connected to walrus.uccs.edu.
Escape character is '^]'.
GET / HTTP/1.0
HTTP/1.1 200 OK
Date: Thu, 26 Jan 2012 00:49:07 GMT
Server: Apache/2.2.21 (Fedora)
Last-Modified: Sat, 31 Dec 2011 22:56:12 GMT
ETag: "1a0185-1ca6-4b56b418dfc77"
Accept-Ranges: bytes
Content-Length: 7334
Connection: close
Content-Type: text/html; charset=UTF-8
Part1. Exercise1: Configure a simple apache server (ws1)
- Login to viva (use SSH)
- cd public_html/cs526
- run "./setup.pl jlogan 345" to configure ws1 site. Replace jlogan with your login and 345 with the last three digits of your SID.
- cd apache/ws1 and make sure
- in the cmd, conf/httpd.conf, htdocs directory files, all instances of LOGIN are replaced with your own login name and
- in the conf/httpd.conf file, the port number with 8<last
3 digits of your SID> in the Listen directive are replaced with the last 3 digits of your SID.
- Make sure you have mime.types in your conf directory (new apache2 requirement).
- Run the apache web server with
"./cmd "
- Go to any browser and enter "http://viva.uccs.edu:8<last
3 digits of your SID>", e.g., http://viva.uccs.edu:8345/, and see if the web page shows
up.
- Check the logs in ws1/logs/access_log and see the access records is created. You can also type the url http://viva.uccs.edu/~jlogan/cs526/apache/ws1/logs/access_log (replace jlogan with your login name).
Part1. Exercise2: Setup web server 2 on walrus
- Createa another SSH terminal window and login to walrus.
- cd public_html/cs526
- run "./setup.pl jlogan 345" to configure apache site. Replace jlogan with your login and 345 with the last three digits of your SID.
- cd apache/ws2 and make sure
- in the cmd, conf/httpd.conf, htdocs directory files, all instances of LOGIN are replaced with your own login name and
- in the conf/httpd.conf file, the port number with 8<last
3 digits of your SID> in the Listen directive are replaced with the last 3 digits of your SID.
- Make sure you have mime.types in your conf directory (new apache2 requirement).
- Run the apache web server with
"./cmd "
- Go to any browser and enter "http://walrus.uccs.edu:8<last
3 digits of your SID>", e.g., http://walrus.uccs.edu:8345/, and see if the web page shows
up.
- Check the logs in ws2/logs/access_log
and see the access records is created. You can also type the url http://walrus.uccs.edu/~jlogan/cs526/apache/ws2/logs/access_log
Part1. Exercise3: Setup web server 3 on wins.csnet.
- Createa another SSH terminal window and login to wins.csnet
- cd public_html/cs526
- run "./setup.pl jlogan 345" to configure apache site. Replace jlogan with your login and 345 with the last three digits of your SID.
- cd apache/ws3 and make sure
- in the cmd, conf/httpd.conf, htdocs directory files, all instances of LOGIN are replaced with your own login name and
- in the conf/httpd.conf file, the port number with 8<last
3 digits of your SID> in the Listen directive are replaced with the last 3 digits of your SID.
- Make sure you have mime.types in your conf directory (new apache2 requirement).
- Run the apache web server with
"./cmd "
- Go to any browser and enter "http://wins.csnet.uccs.edu:8<last
3 digits of your SID>", e.g., http://wins.csnet.uccs.edu:8345/, and see if the web page shows
up.
- Check the logs in ws3/logs/access_log
and see the access records is created. You can also type the url http://wins.csnet.uccs.edu/~jlogan/cs526/apache/ws3/logs/access_log
Create a homework web page hw2.html
in your cs526 personal web page directory