Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

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- 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. 9/20/2018 C. Edward Chow

2 Web Server Installation Statistics
9/20/2018 C. Edward Chow

3 Compiling Apache_1.3.12 Download apache_ tar.gz from or closer mirror sites $tar xzvf apache_ tar.gz $ ./configure --prefix=PREFIX $ make $ make install $ PREFIX/bin/apachectl start Here PREFIX is the prefix of the directory containing the distribution, typically it is /usr/local/apache. 9/20/2018 C. Edward Chow

4 CS401 Apache Testbed bilbo.uccs.edu and frodo.uccs.edu are installed with Apache /mpc/home/www/sites contains the configuration files of various web sites contained in the CD-ROM of Apache text. See for more detail on how to carry out the exercise. Copy /mpc/home/www/sites to your directory. To avoid conflict, use port # = 8<last 3 digits of SS#> Add “Port 8<last 3 digits of SS#>“ to httpd.conf. 9/20/2018 C. Edward Chow

5 Apache Exercise Setup Replace domain name/IP address on 3rd left Linux PC with bilbo.uccs.edu sales.butterthlies.com with b2b.uccs.edu with wait.uccs.edu Replace domain name/IP address on 4th left Linux PC with frodo.uccs.edu sales.butterthlies.com with feline.uccs.edu with walden.uccs.edu Replace domain name/IP address on 5th left Linux PC with gandalf.uccs.edu sales.butterthlies.com with gallop.uccs.edu with wind.uccs.edu 9/20/2018 C. Edward Chow

6 Apache Testbed: LAN Setup
/usr/www/lan_setup script for bilbo: ifconfig eth ifconfig eth0: ifconfig eth0: Or on linuxconf for bilbo, select config | networking | IP aliases for virtual hosts | eth0. Type in , 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). 9/20/2018 C. Edward Chow

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 eth0:1 down to shut down the IP aliase. Use ifconfig eth0:1 up to bring it up again. 9/20/2018 C. Edward Chow

8 Apache Web Site Exercises
Each site.<exercise> 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.<name> -X” -d for the site directory, -X single process execution Edit the httpd.conf file. Add the following lines Port 8<last 3 digits of your SS#> TransferLog /mpc/home/<login>/sites/site.<name>/logs/access_log In go shell script file, replace xxSITESxx with /mpc/home/<login>/sites replace <name> with the corresponding site name. Type go to start the web server 9/20/2018 C. Edward Chow

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 <site>/logs/error_log” or “ps aux | grep webuser” to see if the server is configured and running. [Sat Feb 7 20:23: ] Server configured -- resuming normal operations or webuser ? S 20:23 0:00 httpd -d /home/cs401 “tail -f <site>/logs/access_log” to see the processing results of client requests usrp16.uccs.edu - - [07/Feb/1998:03:21: ] "GET / HTTP/1.0" Use a browser (on vinci or other machines) to access the server a few times with url = “kill `cat <site>/logs/httpd.pid`” to terminate web server. note that it is back quote ` and not ‘ 9/20/2018 C. Edward Chow

10 Httpd Configuration File
Apache uses a set of (73) directives to describe to httpd how the web site should be configured. 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 9/20/2018 C. Edward Chow

11 Block Directives Directives that limit the application of other directives. Specify by a group like a tag section in html. <VirtualHost host[:port]> ... </VirtualHost> <VirtualHost…><Directory dir>, <Files file>, <Location URL> in ascending order of authority. <Location> can overwrite others. dir, file, URL can specify using wildcards and full regular expressions preceded by “~” 9/20/2018 C. Edward Chow

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 ServerAdmin: 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 “|rotatelogs” The file is relative to the server root directory (specified in httpd -d <server root> or /usr/local/etc/httpd) 9/20/2018 C. Edward Chow

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

14 Homework#3 Exercise 1: Site.toddle and Site.simple
“cp -r /mpc/home/www/sites /mpc/home/<login>“ Edit the httpd.conf in conf directory DocumentRoot /usr/www/site.simple/htdocs  DocumentRoot /mpc/home/<login>/sites/site.simple/htdocs Port 8<last 3 digits of your SS#> TransferLog logs/access_log Edit go shell script “httpd -d /mpc/home/<login>/sites/site.<name> [-X]“ go 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 or depending which machine Check the access_log file. Keep them as record 9/20/2018 C. Edward Chow

15 Homework#3 Exercise 1 User webuser Group webgroup
ServerName bilbo.uccs.edu or frodo.uccs.edu DocumentRoot /mpc/home/<login>/sites/site.toddle/htdocs Port 8<last 3 digits of your SS#> TransferLog logs/access_log 9/20/2018 C. Edward Chow

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 with bilbo.uccs.edu add Port 8<last 3 digits of SS#> 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.conf replace sales.butterthlies.com with b2b.uccs.edu Replace Listen sales.butterthlies.com:80 with Listen b2b.uccs.edu:8<last 3 digits of SS#> httpd -d /mpc/home/<login>/sites/site.twocopy/customers -X httpd -d /mpc/home/<login>/sites/site.twocopy/sales -X 9/20/2018 C. Edward Chow

17 Web Hosting Named-based vs. IP-based Virtual Host (VH) HOST: <name> a unique IP address for each VH on metaheader different to support a lot of VHs old browsers not support this Use <VirtualHost hostname[:port]> 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. 9/20/2018 C. Edward Chow

18 Site.Virtual/Name-based
cd /mpc/home/<login>/sites/site.virtual/Name-based edit the httpd.conf in conf directory: NameVirtualHost  NameVirtualHost Port 8<last 3 digits of SS#> <VirtualHost  <VirtualHost bilbo.uccs.edu:portno> Here portno is 8<last 3 digits of your SS#> ServerAdmin  ServerAdmin /usr/www  /mpc/home/<login>/sites/ <VirtualHost sales.butterthlies.com>  <VirtualHost sales-bilbo.uccs.edu:portno> Go to start virtual hositng. 9/20/2018 C. Edward Chow

19 Site.Virtual/IP-based
cd /mpc/home/<login>/sites/site.virtual/IP-based edit the httpd.conf in conf directory: Add Port 8<last 3 digits of SS#> right after Group webgroup <VirtualHost >  <VirtualHost :portno> Here portno is 8<last 3 digits of your SS#> ServerName bilbo.uccs.edu ServerAdmin  ServerAdmin /usr/www  /mpc/home/<login>/sites/ <VirtualHost >  <VirtualHost :portno> ServerName b2b.uccs.edu 9/20/2018 C. Edward Chow

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 :8888 Port 8888 <VirtualHost bilbo.csnet.uccs.edu:8888> DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/customers <VirtualHost salesbilbo.csnet.uccs.edu:8888> DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen <VirtualHost :8888> 9/20/2018 C. Edward Chow

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 <VirtualHost :7888> DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/customers <VirtualHost :8888> DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen 9/20/2018 C. Edward Chow

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 Try to explain why this happens. A good answer gets 1 point count towards final grade. 9/20/2018 C. Edward Chow

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 when you finish both exercises. 9/20/2018 C. Edward Chow

24 Homework #3: Problem 3 Explain why it is possible not to require a new IP address to host a customer’s web site, even though it has a unique domain name. 9/20/2018 C. Edward Chow


Download ppt "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."

Similar presentations


Ads by Google