CS401 Page 1

About This Presentation
Title:

CS401 Page 1

Description:

In go shell script file, replace xxSITESxx with /mpc/home/ login /sites ... Specify by a group like a tag section in html. VirtualHost host[:port] /VirtualHost ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 25
Provided by: csU75
Learn more at: http://cs.uccs.edu

less

Transcript and Presenter's Notes

Title: CS401 Page 1


1
Apache Web Server
  • A PAtCHy server developed by the Apache group
    formed 2/95 around a number of people who
    provided patch files for NCSA httpd 1.3 by Rob
    McCool.
  • History-http//www.apache.org/ABOUT_APACHE.html
  • First official public release (0.6.2) in April
    1995
  • Add adaptive pre-fork child processes (very
    important!).
  • Modular structure and API for extensibility (Bob
    Thau)
  • Port to multiple platforms. Add documentation.
  • Apache 1.0 was released on 12/1/95.Pass NCSA
    httpd to be 1 server in Internet.

2
Web Server Installation Statistics
  • http//www.netcraft.co.uk/survey/

3
Compiling Apache_1.3.12
  • Download apache_1.3.12.tar.gz from
    http//www.apache.org/dist or closer mirror sites
  • tar xzvf apache_1.3.12.tar.gz
  • ./configure --prefixPREFIX
  • make
  • make install
  • PREFIX/bin/apachectl start
  • Here PREFIX is the prefix of the directory
    containing the distribution, typically it is
    /usr/local/apache.

4
CS401 Apache Testbed
  • bilbo.uccs.edu and frodo.uccs.edu are installed
    with Apache1.3.12.
  • /mpc/home/www/sites contains the configuration
    files of various web sites contained in the
    CD-ROM of Apache text.
  • See http//cs.uccs.edu/cs401/cs401lab.html for
    more detail on how to carry out the exercise.
  • Copy /mpc/home/www/sites to your directory.
  • To avoid conflict, use port 8ltlast 3 digits
    of SSgtAdd Port 8ltlast 3 digits of SSgt to
    httpd.conf.

5
Apache Exercise Setup
  • Replace domain name/IP address on 3rd left Linux
    PC
  • www.butterhlies.com 192.168.123.2 with
    bilbo.uccs.edu 128.198.192.182
  • sales.butterthlies.com 192.168.123.3 with
    b2b.uccs.edu 128.198.192.172
  • www.faraway.com 192.168.124.1 with wait.uccs.edu
    128.198.192.202
  • Replace domain name/IP address on 4th left Linux
    PC
  • www.butterhlies.com 192.168.123.2 with
    frodo.uccs.edu 128.198.192.183
  • sales.butterthlies.com 192.168.123.3 with
    feline.uccs.edu 128.198.192.173
  • www.faraway.com 192.168.124.1 with
    walden.uccs.edu 128.198.192.203
  • Replace domain name/IP address on 5th left Linux
    PC
  • www.butterhlies.com 192.168.123.2 with
    gandalf.uccs.edu 128.198.192.194
  • sales.butterthlies.com 192.168.123.3 with
    gallop.uccs.edu 128.198.192.174
  • www.faraway.com 192.168.124.1 with wind.uccs.edu
    128.198.192.204

6
Apache Testbed LAN Setup
  • /usr/www/lan_setup script for bilbo
  • ifconfig eth0 128.198.192.182
  • ifconfig eth00 128.198.192.172
  • ifconfig eth01 128.198.192.202
  • Or on linuxconf for bilbo, selectconfig
    networking IP aliases for virtual hosts eth0.
    Type in 128.198.192.172, 128.198.192.202 for IP
    aliases(I have not succeeded in using the above
    method.)
  • Normally we skip lan_setup. We will share the
    same lan_setup. Run the above lan_setup if you
    find the computer is configured incorrectly
    (through ifconfig).

7
Ifconfig command
  • Interface configuration command.
  • There is an equivalent command ipconfig on win32.
  • In Redhat linux, it is in /sbin. I have modified
    /etc/profile to include that directory in PATH.
  • Use ifconfig to show the status
  • Use ifconfig eth01 down to shut down the IP
    aliase.
  • Use ifconfig eth01 up to bring it up again.

8
Apache Web Site Exercises
  • Each site.ltexercisegt directory contains
  • conf configuration files, httpd.conf, srm.conf,
    access.conf, mime.types
  • htdocs contains web pages, scripts
  • logs access_log, error_log, httpd.pid,
    (referer_log, agent_log)
  • go alias of httpd -d xxSITESxx/site.ltnamegt
    -X-d for the site directory, -X single process
    execution
  • Edit the httpd.conf file. Add the following
    lines Port 8ltlast 3 digits of your SSgt
    TransferLog /mpc/home/ltlogingt/sites/site.ltnamegt/lo
    gs/access_log
  • In go shell script file, replace xxSITESxx with
    /mpc/home/ltlogingt/sitesreplace ltnamegt with the
    corresponding site name.
  • Type go to start the web server

9
Examine httpd Configuration
  • To enhance the security, webuser is created to
    run httpd
  • Add User webuser and Group webgroup to
    httpd.conf.
  • tail -f ltsitegt/logs/error_log or ps aux
    grep webuser to see if the server is configured
    and running.Sat Feb 7 202357 1998 Server
    configured -- resuming normal operations
    orwebuser 13013 0.0 2.2 1260 704 ? S
    2023 000 httpd -d /home/cs401
  • tail -f ltsitegt/logs/access_log to see the
    processing results of client requestsusrp16.uccs.
    edu - - 07/Feb/1998032116 -0700 "GET /
    HTTP/1.0" 200 170
  • Use a browser (on vinci or other machines) to
    accessthe server a few times with url
    http//bilbo8345/
  • kill cat ltsitegt/logs/httpd.pid to terminate
    web server.note that it is back quote and not

10
Httpd Configuration File
  • Apache uses a set of (73) directives to describe
    to httpd how the web site should be configured.
    http//www.apache.org/docs/mod/directives.html
  • Each Apache configuration directive is described
    using a common format that looks like this
  • Syntax directive-name some args
  • Default directive-name default-value
  • Context context-list
  • Override override
  • Status status
  • Module module-name
  • Compatibility compatibility notes

11
Block Directives
  • Directives that limit the application of other
    directives.
  • Specify by a group like a tag section in html.
  • ltVirtualHost hostportgt...lt/VirtualHostgt
  • ltVirtualHostgtltDirectory dirgt, ltFiles filegt,
    ltLocation URLgt in ascending order of authority.
    ltLocationgt can overwrite others.
  • dir, file, URL can specify using wildcards and
    full regular expressions preceded by

12
List of Directives
  • User, Group specify user and group that httpd
    runs on.
  • ServerName hostname of server (for redirection
    URL)
  • ResourceConfig, AccessConfig for reading
    additional related directives. Can be disabled by
    /dev/null as value
  • Port specify the port httpd run on
  • ServerAdminemail addr. for browser to do
    automatic replies.
  • DocumentRoot
  • TransferLog, ErrorLog, PidFile where
    access,error logs, httpd.pid should be located.
    Can be file or pipe rotatelogsThe file is
    relative to the server root directory(specified
    in httpd -d ltserver rootgt or /usr/local/etc/httpd)

13
Directives
  • KeepAlive onoff(on) keep connection alive for
    n requests before terminate provided they come in
    before timeout. n is defined in
    MaxKeepAliveRequests ltngt(100) directive
  • KeepAliveTimeout ltngt(15) wait for the next
    request for n seconds before terminate the
    connections.
  • Timeout ltngt(300) max. time in sec for a block
    data.
  • HostNameLookups onoffdouble(off) do reverse
    DNS lookup for logging the domain name of the
    request.
  • MaxClients ltngt(256) the limit of of
    simultaneous requests (hence the of child
    processes).
  • MaxRequestsPerChild ltngt(0) Spare(child) server
    dies after ltngt requests, avoid mem leak. 0 mean
    infinite requests.
  • Min/MaxSpareServers ltngt(5/10) of Idle child
    servers
  • StartServers ltngt(5) sets the number of child
    server processes created on startup.

14
Homework3 Exercise 1Site.toddle and Site.simple
  • cp -r /mpc/home/www/sites
    /mpc/home/ltlogingt
  • Edit the httpd.conf in conf directoryDocumentRoot
    /usr/www/site.simple/htdocs ?DocumentRoot
    /mpc/home/ltlogingt/sites/site.simple/htdocs Port
    8ltlast 3 digits of your SSgtTransferLog
    logs/access_log
  • Edit go shell script httpd -d
    /mpc/home/ltlogingt/sites/site.ltnamegt -Xgo in
    the site.simple does not have X.
  • go will start the web server. Control-c will
    terminate it.
  • Use browser to visit the site a few times.
    Remember to specify the port in url. For IE
    browser, type http//bilbo.uccs.edultportnogt/ or
    http//frodo.uccs.edultportnogt/ depending which
    machine
  • Check the access_log file. Keep them as record

15
Homework3 Exercise 1
  • User webuser
  • Group webgroup
  • ServerName bilbo.uccs.edu or frodo.uccs.edu
  • DocumentRoot /mpc/home/ltlogingt/sites/site.toddle/h
    tdocs
  • Port 8ltlast 3 digits of your SSgt
  • TransferLog logs/access_log

16
Site.twocopy
  • Create two web servers one serves customers one
    for sales. There are two directories in
    site.twocopy.
  • In customers/conf/httpd.conf,replace
    www.butterthlies.com with bilbo.uccs.eduadd Port
    8ltlast 3 digits of SSgt
  • Here BindAddress is used to specify the reception
    of request from specific IP address (domain name)
    by this web server. BindAddress bilbo.uccs.edu
  • In sales/conf/httpd.confreplace
    sales.butterthlies.com with b2b.uccs.eduReplace
    Listen sales.butterthlies.com80 withListen
    b2b.uccs.edu8ltlast 3 digits of SSgt
  • httpd -d /mpc/home/ltlogingt/sites/site.twocopy/cust
    omers -X
  • httpd -d /mpc/home/ltlogingt/sites/site.twocopy/sale
    s -X

17
Web Hosting
  • Named-based vs. IP-based Virtual Host
    (VH)HOST ltnamegt a unique IP address for
    each VHon metaheader different to
    support a lot of VHsold browsers notsupport
    this
  • Use ltVirtualHost hostnameportgt block
    directives
  • Specify ServerAdmin, DocumentRoot, ServerName,
    ErrorLog, TransferLog for individual VH
  • Be aware that UNIX File Limits on of file
    descriptors. (default 64) ? only support 32 VHs?
  • You may want to increase of child servers.

18
Site.Virtual/Name-based
  • cd /mpc/home/ltlogingt/sites/site.virtual/Name-base
    d
  • edit the httpd.conf in conf directory
  • NameVirtualHost 192.168.123.2 ?NameVirtualHost
    128.198.192.182Port 8ltlast 3 digits of SSgt
  • ltVirtualHost www.butterthlies.comgt ?ltVirtualHost
    bilbo.uccs.eduportnogtHere portno is 8ltlast 3
    digits of your SSgt
  • ServerAdmin sales_at_butterthlies.com ? ServerAdmin
    ltlogingt_at_cs.uccs.edu
  • /usr/www ? /mpc/home/ltlogingt/sites/
  • ltVirtualHost sales.butterthlies.comgt
    ?ltVirtualHost sales-bilbo.uccs.eduportnogt
  • Go to start virtual hositng.

19
Site.Virtual/IP-based
  • cd /mpc/home/ltlogingt/sites/site.virtual/IP-based
  • edit the httpd.conf in conf directory
  • Add Port 8ltlast 3 digits of SSgt right after
    Group webgroup
  • ltVirtualHost 192.168.123.2gt ?ltVirtualHost
    128.198.192.182portnogtHere portno is 8ltlast 3
    digits of your SSgt
  • ServerName bilbo.uccs.edu
  • ServerAdmin sales_at_butterthlies.com ? ServerAdmin
    ltlogingt_at_cs.uccs.edu
  • /usr/www ? /mpc/home/ltlogingt/sites/
  • ltVirtualHost 192.168.123.3gt ?ltVirtualHost
    128.198.192.172portnogt
  • ServerName b2b.uccs.edu

20
Site.Virtual/Mixed-based
  • We can mix Name-based with IP-based virtual
    hosting.
  • Change IP-based to Mixed-based. An error in
    config file.
  • NameVirtualHost 128.198.192.1828888
  • Port 8888
  • ltVirtualHost bilbo.csnet.uccs.edu8888gt
  • DocumentRoot /mpc/home/guest/sites/site.virtual/ht
    docs/customers
  • ltVirtualHost salesbilbo.csnet.uccs.edu8888gt
  • DocumentRoot /mpc/home/guest/sites/site.virtual/ht
    docs/salesmen
  • ltVirtualHost 128.198.192.1728888gt
  • DocumentRoot /mpc/home/guest/sites/site.virtual/ht
    docs/salesmen

21
Port-based Virtual Hosting
  • Can use one IP address to test many sites.
  • Change IP-based to Port-based. An error in
    config file.
  • Different ports map to different sites.
  • User webuser
  • Group webgroup
  • Listen 7888
  • Listen 8888
  • ltVirtualHost 128.198.192.1827888gt
  • DocumentRoot /mpc/home/guest/sites/site.virtual/ht
    docs/customers
  • ltVirtualHost 128.198.192.1828888gt
  • DocumentRoot /mpc/home/guest/sites/site.virtual/ht
    docs/salesmen

22
Bonus Exercise 1
  • After copying the site.virtual to the nfs mount
    dir and executing the httpd, the access_log and
    error_log files are empty.
  • When use the directory mounted on local disk,
    there are no problem.
  • See the bonus exercise on http//owl/cs401/bonus.
    html
  • Try to explain why this happens.
  • A good answer gets 1 point count towards final
    grade.

23
Homework 3 Exercise 2
  • Run site.virtual/Name-based, site.virtual/IP-based
    , and site.twocopy according to the textbook and
    verify the results.
  • Keep the access_log and error_log as records.
  • Send me email when you finish both exercises.

24
Homework 3 Problem 3
  • Explain why it is possible not to require a new
    IP address to host a customers web site, even
    though it has a unique domain name.
Write a Comment
User Comments (0)