apache httpd web server c. edward chow. advanced internet & web systems chow2 outline of the...

21
Apache httpd Web Server Apache httpd Web Server C. Edward Chow C. Edward Chow

Upload: nicholas-reynold-pope

Post on 23-Dec-2015

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Apache httpd Web ServerApache httpd Web ServerApache httpd Web ServerApache httpd Web Server

C. Edward ChowC. Edward ChowC. Edward ChowC. Edward Chow

Page 2: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 2

Outline of the TalkOutline of the TalkOutline of the TalkOutline of the Talk

Introduction to Apache httpd web serverIntroduction to Apache httpd web server

Basic Compilation, Installation and Basic Compilation, Installation and ConfigurationConfiguration

Performance Features: Prefork, Performance Features: Prefork,

Cache and Proxy moduleCache and Proxy module

Virtual HostingVirtual Hosting

Reference: Reference: http://httpd.apache.org/docs/2.2/http://httpd.apache.org/docs/2.2/

Page 3: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 3

Apache Web ServerApache Web ServerA PAtCHy server: developed by the Apache group formed A PAtCHy server: developed by the Apache group formed 2/95 around a number of people who provided patch files 2/95 around a number of people who provided patch files for NCSA httpd 1.3 by Rob McCool.for NCSA httpd 1.3 by Rob McCool.

History-http://httpd.apache.org/ABOUT_APACHE.htmlHistory-http://httpd.apache.org/ABOUT_APACHE.html

First official public release (0.6.2) in April 1995First official public release (0.6.2) in April 1995

Add adaptive pre-fork child processes (very important!).Add adaptive pre-fork child processes (very important!).

Modular structure and API for extensibility (Bob Thau)Modular structure and API for extensibility (Bob Thau)

Port to multiple platforms. Add documentation.Port to multiple platforms. Add documentation.

Apache 1.0 was released on 12/1/95.Apache 1.0 was released on 12/1/95.Pass NCSA httpd to be #1 server in Internet.Pass NCSA httpd to be #1 server in Internet.

Page 4: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 4

Web Server Installation Web Server Installation StatisticsStatisticsWeb Server Installation Web Server Installation StatisticsStatistics

See survey statistics in See survey statistics in http://news.netcraft.com/archives/web_server_survey.htmlSee survey statistics in See survey statistics in http://news.netcraft.com/archives/web_server_survey.html

Page 5: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 5

Apache httpd ReleasesApache httpd ReleasesApache httpd ReleasesApache httpd ReleasesThe current stable release is Apache 2.2.17.The current stable release is Apache 2.2.17.

For win32 version, you can download from any of For win32 version, you can download from any of mirror servers. Win32 Binary including OpenSSL mirror servers. Win32 Binary including OpenSSL 0.9.8o (MSI Installer). 0.9.8o (MSI Installer). http://httpd.apache.org/download.cgihttp://httpd.apache.org/download.cgi

Our CS Unix machines currently running Apache Our CS Unix machines currently running Apache 2.2.32.2.3

Gandalf, walrus, viva, chow.csnet running Apache Gandalf, walrus, viva, chow.csnet running Apache 2.2.17.2.2.17.

The current stable release is Apache 2.2.17.The current stable release is Apache 2.2.17.

For win32 version, you can download from any of For win32 version, you can download from any of mirror servers. Win32 Binary including OpenSSL mirror servers. Win32 Binary including OpenSSL 0.9.8o (MSI Installer). 0.9.8o (MSI Installer). http://httpd.apache.org/download.cgihttp://httpd.apache.org/download.cgi

Our CS Unix machines currently running Apache Our CS Unix machines currently running Apache 2.2.32.2.3

Gandalf, walrus, viva, chow.csnet running Apache Gandalf, walrus, viva, chow.csnet running Apache 2.2.17.2.2.17.

Page 6: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

New Features in Apache New Features in Apache 2.22.2New Features in Apache New Features in Apache 2.22.2Multi-Processing Module (MPM) Support.Multi-Processing Module (MPM) Support.

Customized for the needs of the particular site. Customized for the needs of the particular site. threaded MPM, like worker or event threaded MPM, like worker or event scalability scalability

prefork prefork stability or compatibility with older stability or compatibility with older software.software.

MPM support for different OS’ (native MPM support for different OS’ (native networking feature mpm_winnt; beos, os2)networking feature mpm_winnt; beos, os2)

IPv6 Support.IPv6 Support.For example, the listen directive syntax IPv6 addresses must be For example, the listen directive syntax IPv6 addresses must be surrounded in square brackets, as in the following example:surrounded in square brackets, as in the following example: Listen Listen [[2001:db8::a00:20ff:fea7:ccea2001:db8::a00:20ff:fea7:ccea]]::8080

CachingCachingProduction quality disk caching and memory Production quality disk caching and memory caching.caching.

htcacheclean to clean up mod_disk_cache htcacheclean to clean up mod_disk_cache setupssetups

Multi-Processing Module (MPM) Support.Multi-Processing Module (MPM) Support.Customized for the needs of the particular site. Customized for the needs of the particular site.

threaded MPM, like worker or event threaded MPM, like worker or event scalability scalability

prefork prefork stability or compatibility with older stability or compatibility with older software.software.

MPM support for different OS’ (native MPM support for different OS’ (native networking feature mpm_winnt; beos, os2)networking feature mpm_winnt; beos, os2)

IPv6 Support.IPv6 Support.For example, the listen directive syntax IPv6 addresses must be For example, the listen directive syntax IPv6 addresses must be surrounded in square brackets, as in the following example:surrounded in square brackets, as in the following example: Listen Listen [[2001:db8::a00:20ff:fea7:ccea2001:db8::a00:20ff:fea7:ccea]]::8080

CachingCachingProduction quality disk caching and memory Production quality disk caching and memory caching.caching.

htcacheclean to clean up mod_disk_cache htcacheclean to clean up mod_disk_cache setupssetups

Advanced Internet & Web Systems

chow 6

Page 7: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

New Features in Apache New Features in Apache 2.22.2New Features in Apache New Features in Apache 2.22.2Smart FilteringSmart Filtering

Output filter chain called dynamically configured.Output filter chain called dynamically configured.

Filters can be conditionally inserted based on Filters can be conditionally inserted based on Request/Response header or env variables.Request/Response header or env variables.

Proxy_BalancerProxy_BalancerJserv Support for Apache Tomcat.Jserv Support for Apache Tomcat.

3 load balancer scheduler algorithms: 3 load balancer scheduler algorithms: Weighted Request Weighted Request CountingCounting, Weighted Traffic (byte) Counting, and Pending , Weighted Traffic (byte) Counting, and Pending Request Counting. Request Counting.

ProxyPass / balancer://mycluster/ ProxyPass / balancer://mycluster/ stickysessionstickysession=JSESSIONID|=JSESSIONID|jsessionid nofailover=Onjsessionid nofailover=On<Proxy balancer://mycluster><Proxy balancer://mycluster>

BalancerMember http://192.168.1.50:80BalancerMember http://192.168.1.50:80

BalancerMember BalancerMember http://192.168.1.51:80

ProxySet lbmethod=bytraffic # default is byterequestProxySet lbmethod=bytraffic # default is byterequest

</Proxy></Proxy>

ProxyPass /test balancer://myclusterProxyPass /test balancer://mycluster

Smart FilteringSmart FilteringOutput filter chain called dynamically configured.Output filter chain called dynamically configured.

Filters can be conditionally inserted based on Filters can be conditionally inserted based on Request/Response header or env variables.Request/Response header or env variables.

Proxy_BalancerProxy_BalancerJserv Support for Apache Tomcat.Jserv Support for Apache Tomcat.

3 load balancer scheduler algorithms: 3 load balancer scheduler algorithms: Weighted Request Weighted Request CountingCounting, Weighted Traffic (byte) Counting, and Pending , Weighted Traffic (byte) Counting, and Pending Request Counting. Request Counting.

ProxyPass / balancer://mycluster/ ProxyPass / balancer://mycluster/ stickysessionstickysession=JSESSIONID|=JSESSIONID|jsessionid nofailover=Onjsessionid nofailover=On<Proxy balancer://mycluster><Proxy balancer://mycluster>

BalancerMember http://192.168.1.50:80BalancerMember http://192.168.1.50:80

BalancerMember BalancerMember http://192.168.1.51:80

ProxySet lbmethod=bytraffic # default is byterequestProxySet lbmethod=bytraffic # default is byterequest

</Proxy></Proxy>

ProxyPass /test balancer://myclusterProxyPass /test balancer://myclusterAdvanced Internet & Web Systems

chow 7

Page 8: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 8

Compiling httpd-2.2.0Compiling httpd-2.2.0Download httpd-2.2.0.tar.bz2 from Download httpd-2.2.0.tar.bz2 from http://www.apache.org/dist or closer or closer mirror sitesmirror sites$tar xjf httpd-2.2.0.tar.bz2$tar xjf httpd-2.2.0.tar.bz2$ ./configure --prefix=PREFIX$ ./configure --prefix=PREFIX$ make$ make$ make install$ make install$ PREFIX/bin/apachectl start $ PREFIX/bin/apachectl start

Here PREFIX is the prefix of the directory containing the distribution, Here PREFIX is the prefix of the directory containing the distribution, typically it is /usr/local/apache.typically it is /usr/local/apache.Since as a normal user, we donot have permission to install there, I Since as a normal user, we donot have permission to install there, I specify PREFIX as specify PREFIX as /users/server/students/cs526/public_html/apache2.2m/httpd-/users/server/students/cs526/public_html/apache2.2m/httpd-2.2.02.2.0For configuring the apache with specific features, we can For configuring the apache with specific features, we can specify the corresponding features as option to the configure specify the corresponding features as option to the configure command. You can find the list of features by “./configure –command. You can find the list of features by “./configure –help”help”Here is the command we used to compile the htttpd with proxy Here is the command we used to compile the htttpd with proxy and cache modules we need.and cache modules we need.

Page 9: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 9

Configure Apache (http and Configure Apache (http and https) on Redhat 9https) on Redhat 9Configure Apache (http and Configure Apache (http and https) on Redhat 9https) on Redhat 9

Apache HTTP Server Configuration Apache HTTP Server Configuration http://www.redhat.com/docs/manuals/linuxhttp://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-/RHL-9-Manual/custom-guide/ch-httpdconfig.htmlhttpdconfig.html

Apache HTTP Secure Server Configuration Apache HTTP Secure Server Configuration http://www.redhat.com/docs/manuals/linuxhttp://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-httpd-/RHL-9-Manual/custom-guide/ch-httpd-secure-server.htmlsecure-server.html

Apache HTTP Server Configuration Apache HTTP Server Configuration http://www.redhat.com/docs/manuals/linuxhttp://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-/RHL-9-Manual/custom-guide/ch-httpdconfig.htmlhttpdconfig.html

Apache HTTP Secure Server Configuration Apache HTTP Secure Server Configuration http://www.redhat.com/docs/manuals/linuxhttp://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-httpd-/RHL-9-Manual/custom-guide/ch-httpd-secure-server.htmlsecure-server.html

Page 10: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 10

Apache Exercises Apache Exercises Each site.<exercise> directory containsEach site.<exercise> directory contains

conf: configuration files, httpd.conf, mime.typesconf: configuration files, httpd.conf, mime.types

htdocs: contains web pageshtdocs: contains web pages

logs: access_log, error_log, httpd.pidlogs: access_log, error_log, httpd.pid

cmd: alias of “<path>httpd -d serverrootDirectory -X”cmd: alias of “<path>httpd -d serverrootDirectory -X”Here <path> specify the directory contains the httpd programHere <path> specify the directory contains the httpd program-d specifies the server root directory, -X single process execution-d specifies the server root directory, -X single process execution

Edit the httpd.conf file. Add the following linesEdit the httpd.conf file. Add the following lines Listen 8<last 3 digits of your SS#>Listen 8<last 3 digits of your SS#> TransferLog /user/server/students/<login>/sites/site.<name>/logs/access_logTransferLog /user/server/students/<login>/sites/site.<name>/logs/access_log

See detailed in homework exercise.See detailed in homework exercise.replace <name> with the corresponding site name.replace <name> with the corresponding site name.

Type Type cmdcmd to start the web server to start the web server

Page 11: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 11

Examine ConfigurationExamine ConfigurationTo security and access reason, we use our login and is created to run httpdTo security and access reason, we use our login and is created to run httpd

Add “User <login>” and “Group <login>” to httpd.conf.Add “User <login>” and “Group <login>” to httpd.conf.

““tail -f <site>/logs/error_log” or “ps aux | grep <login>” to see if the server is tail -f <site>/logs/error_log” or “ps aux | grep <login>” to see if the server is configured and running.configured and running.[Sat Feb 7 20:23:57 1998] Server configured -- resuming normal [Sat Feb 7 20:23:57 1998] Server configured -- resuming normal operationsoperations or orwebuser 13013 0.0 2.2 1260 704 ? S 20:23 0:00 httpd -d webuser 13013 0.0 2.2 1260 704 ? S 20:23 0:00 httpd -d /home/cs401/home/cs401

““tail -f <site>/logs/access_log” to see the processing results of client requeststail -f <site>/logs/access_log” to see the processing results of client requestsusrp16.uccs.edu - - [07/Feb/1998:03:21:16 -0700] "GET / HTTP/1.0" 200 usrp16.uccs.edu - - [07/Feb/1998:03:21:16 -0700] "GET / HTTP/1.0" 200 170170

Use a browser to access the server a few times with url = Use a browser to access the server a few times with url = http://windom.uccs.edu:8345/ where windom is the machine that runs the http://windom.uccs.edu:8345/ where windom is the machine that runs the httpd and 8345 in your designated port number.httpd and 8345 in your designated port number.

““kill -9 `cat <site>/logs/httpd.pid`” to terminate web server.kill -9 `cat <site>/logs/httpd.pid`” to terminate web server.note that it is back quote ` and not ‘ -9 is -SIGKILLnote that it is back quote ` and not ‘ -9 is -SIGKILL

Page 12: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 12

Httpd Configuration FileHttpd Configuration FileApache uses a set of directives to tell httpd Apache uses a set of directives to tell httpd how the web site should be configured. how the web site should be configured. http://www.apache.org/docs/mod/directives.htmlhttp://www.apache.org/docs/mod/directives.html

Each Apache configuration directive is described using a Each Apache configuration directive is described using a common format that looks like this: common format that looks like this:

Syntax: directive-name some args Syntax: directive-name some args

Default: directive-name default-value Default: directive-name default-value

Context: context-list Context: context-list

Override: override Override: override

Status: status Status: status

Module: module-name Module: module-name

Compatibility: compatibility notesCompatibility: compatibility notes

Page 13: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 13

Block DirectivesBlock DirectivesDirectives that limit the application of Directives that limit the application of other directives.other directives.

Specify by a group like a tag section in Specify by a group like a tag section in html.html.

<VirtualHost host[:port]><VirtualHost host[:port]>......</VirtualHost></VirtualHost>

<VirtualHost…><Directory dir>, <Files <VirtualHost…><Directory dir>, <Files file>, <Location URL> in ascending order file>, <Location URL> in ascending order of authority. <Location> can overwrite of authority. <Location> can overwrite others.others.

dir, file, URL can specify using wildcards dir, file, URL can specify using wildcards and full regular expressions preceded by and full regular expressions preceded by “~”“~”

Page 14: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 14

List of Directives List of Directives User, Group: specify user and group that httpd runs on.User, Group: specify user and group that httpd runs on.

ServerName: hostname of serverServerName: hostname of server

ResourceConfig, AccessConfig: for reading additional related ResourceConfig, AccessConfig: for reading additional related directives. Can be disabled by /dev/null as valuedirectives. Can be disabled by /dev/null as value

Listen: specify the port httpd run on (Port directive is Listen: specify the port httpd run on (Port directive is deprecated)deprecated)

ServerAdmin:ServerAdmin:email addr. for browser to do automatic email addr. for browser to do automatic replies.replies.

DocumentRoot:DocumentRoot:

TransferLog, ErrorLog, PidFile: where access,error logs, TransferLog, ErrorLog, PidFile: where access,error logs, httpd.pid should be located. Can be file or pipe “|rotatelogs”httpd.pid should be located. Can be file or pipe “|rotatelogs”The file is relative to the server root directoryThe file is relative to the server root directory(specified in httpd -d <server root> or /usr/local/etc/httpd)(specified in httpd -d <server root> or /usr/local/etc/httpd)

Page 15: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 15

Performance Related Performance Related DirectivesDirectives

KeepAlive [on|off](on): keep connection alive for n KeepAlive [on|off](on): keep connection alive for n requests before terminate provided they come in before requests before terminate provided they come in before timeout. n is defined in timeout. n is defined in MaxKeepAliveRequests <n>(100) directiveMaxKeepAliveRequests <n>(100) directive

KeepAliveTimeout <n>(15): wait for the next request for KeepAliveTimeout <n>(15): wait for the next request for n seconds before terminate the connections.n seconds before terminate the connections.

Timeout <n>(300): max. time in sec for a block data.Timeout <n>(300): max. time in sec for a block data.

HostNameLookups [HostNameLookups [onon|off|double](off): do reverse DNS |off|double](off): do reverse DNS lookup for logging the domain name of the request.lookup for logging the domain name of the request.

MaxClients <n>(256): the limit of # of simultaneous MaxClients <n>(256): the limit of # of simultaneous requests (hence the # of child processes).requests (hence the # of child processes).

MaxRequestsPerChild <n>(0): Spare(child) server dies MaxRequestsPerChild <n>(0): Spare(child) server dies after <n> requests, avoid mem leak. 0 mean infinite after <n> requests, avoid mem leak. 0 mean infinite requests. requests.

Min/MaxSpareServers <n>(5/10): # of Idle child serversMin/MaxSpareServers <n>(5/10): # of Idle child servers

StartServers <n>(5): sets the number of child server StartServers <n>(5): sets the number of child server processes created on startup.processes created on startup.

Page 16: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 16

Web HostingWeb HostingThere are a few way we can host a web site:There are a few way we can host a web site:

Named-based Virtual Hosting Named-based Virtual Hosting IP-based Virtual HostingIP-based Virtual HostingVirtual Machine Virtual HostingVirtual Machine Virtual Hosting

Name-based Virtual HostingName-based Virtual HostingA set of hostnames A set of hostnames shared the same IP addressshared the same IP address (similar to alias) (similar to alias)utilize the HOST: meta header in http request (browser fill in the utilize the HOST: meta header in http request (browser fill in the hostname) to distinguish different web site.hostname) to distinguish different web site.Each hostname will have its own site configuration, document root.Each hostname will have its own site configuration, document root.Require either the set of hostnames are registered DNS names or the Require either the set of hostnames are registered DNS names or the client machines need to configure their ip addresses mapping in client machines need to configure their ip addresses mapping in hostfiles such as /etc/hosts (Unix) or hostfiles such as /etc/hosts (Unix) or C:\WINDOWS\system32\C:\WINDOWS\system32\drivers\etc\hosts (Windows)drivers\etc\hosts (Windows)

IP-based virtual Hosting:IP-based virtual Hosting:Require a unique IP address for each virtual hosting siteRequire a unique IP address for each virtual hosting siteUse IP alieas to configure the same Network Interface Card (NIC) to Use IP alieas to configure the same Network Interface Card (NIC) to listen to different IP address, e.g., ifconfig eth0listen to different IP address, e.g., ifconfig eth0:1:1 128.198.160.33 128.198.160.33Some Unix system sets limit on how many IP aliases can be supported. Some Unix system sets limit on how many IP aliases can be supported.

Use <VirtualHost hostname[:port]> block directivesUse <VirtualHost hostname[:port]> block directivesSpecify ServerAdmin, DocumentRoot, ServerName, ErrorLog, Specify ServerAdmin, DocumentRoot, ServerName, ErrorLog, TransferLog for individual VHTransferLog for individual VH

Page 17: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 17

Virtual Machine Based Virtual Virtual Machine Based Virtual HostingHostingVirtual Machine Based Virtual Virtual Machine Based Virtual HostingHosting

With Virtual Machine (VMWare/VPC). We can configure With Virtual Machine (VMWare/VPC). We can configure a virtual machine for each web site. This gives each site a virtual machine for each web site. This gives each site total control of the OS of the virtual machine.total control of the OS of the virtual machine.

We can graceful shutdown/restart individual web We can graceful shutdown/restart individual web site (for maintenance/configuration/software site (for maintenance/configuration/software updates). updates).

We cannot graceful shutdown and restart We cannot graceful shutdown and restart individual name-based or IP-based virtual individual name-based or IP-based virtual hosting web sites. They share the same hosting web sites. They share the same Apache httpd, OS, and related software Apache httpd, OS, and related software packages.packages.

We can configure different software package, OS We can configure different software package, OS for each individual web sites.for each individual web sites.

Allow total control for the admin of the web site Allow total control for the admin of the web site (root privilege, user creation, etc)(root privilege, user creation, etc)

Disadvantage: Require more resource (memory, Disadvantage: Require more resource (memory, Disk).Disk).

With Virtual Machine (VMWare/VPC). We can configure With Virtual Machine (VMWare/VPC). We can configure a virtual machine for each web site. This gives each site a virtual machine for each web site. This gives each site total control of the OS of the virtual machine.total control of the OS of the virtual machine.

We can graceful shutdown/restart individual web We can graceful shutdown/restart individual web site (for maintenance/configuration/software site (for maintenance/configuration/software updates). updates).

We cannot graceful shutdown and restart We cannot graceful shutdown and restart individual name-based or IP-based virtual individual name-based or IP-based virtual hosting web sites. They share the same hosting web sites. They share the same Apache httpd, OS, and related software Apache httpd, OS, and related software packages.packages.

We can configure different software package, OS We can configure different software package, OS for each individual web sites.for each individual web sites.

Allow total control for the admin of the web site Allow total control for the admin of the web site (root privilege, user creation, etc)(root privilege, user creation, etc)

Disadvantage: Require more resource (memory, Disadvantage: Require more resource (memory, Disk).Disk).

Page 18: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 18

Site.Virtual/Name-basedSite.Virtual/Name-basedcd cd /mpc/home/<login>/sites/site.virtual/Name-/mpc/home/<login>/sites/site.virtual/Name-basedbased

edit the httpd.conf in conf directory:edit the httpd.conf in conf directory:

NameVirtualHost 192.168.123.2 NameVirtualHost 192.168.123.2 NameVirtualHost 128.198.192.182NameVirtualHost 128.198.192.182Port 8<last 3 digits of SS#>Port 8<last 3 digits of SS#>

<VirtualHost www.butterthlies.com> <VirtualHost www.butterthlies.com> <VirtualHost bilbo.uccs.edu:portno><VirtualHost bilbo.uccs.edu:portno>Here portno is 8<last 3 digits of your SS#>Here portno is 8<last 3 digits of your SS#>

ServerAdmin [email protected] ServerAdmin [email protected] ServerAdmin <login>@cs.uccs.eduServerAdmin <login>@cs.uccs.edu

/usr/www /usr/www /mpc/home/<login>/sites//mpc/home/<login>/sites/

<VirtualHost sales.butterthlies.com> <VirtualHost sales.butterthlies.com> <VirtualHost sales-bilbo.uccs.edu:portno><VirtualHost sales-bilbo.uccs.edu:portno>

Go to start virtual hosting. Go to start virtual hosting.

Page 19: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 19

Site.Virtual/IP-basedSite.Virtual/IP-basedcd /mpc/home/<login>/sites/site.virtual/IP-basedcd /mpc/home/<login>/sites/site.virtual/IP-based

edit the httpd.conf in conf directory:edit the httpd.conf in conf directory:

Add Add Port 8<last 3 digits of SS#>Port 8<last 3 digits of SS#> right after Group webgroupright after Group webgroup

<VirtualHost 192.168.123.2> <VirtualHost 192.168.123.2> <VirtualHost 128.198.192.182:portno><VirtualHost 128.198.192.182:portno>Here portno is 8<last 3 digits of your SS#>Here portno is 8<last 3 digits of your SS#>

ServerName bilbo.uccs.eduServerName bilbo.uccs.edu

ServerAdmin [email protected] ServerAdmin [email protected] ServerAdmin <login>@cs.uccs.eduServerAdmin <login>@cs.uccs.edu

/usr/www /usr/www /mpc/home/<login>/sites//mpc/home/<login>/sites/

<VirtualHost 192.168.123.3> <VirtualHost 192.168.123.3> <VirtualHost 128.198.192.172:portno><VirtualHost 128.198.192.172:portno>

ServerName b2b.uccs.eduServerName b2b.uccs.edu

Page 20: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 20

Site.Virtual/Mixed-basedSite.Virtual/Mixed-basedSite.Virtual/Mixed-basedSite.Virtual/Mixed-basedWe can mix Name-based with IP-based virtual hosting.We can mix Name-based with IP-based virtual hosting.

Change “Change “IP-basedIP-based” to “” to “Mixed-basedMixed-based”. An error in config file.”. An error in config file.

NameVirtualHost 128.198.192.182:8888NameVirtualHost 128.198.192.182:8888

Port 8888Port 8888

<VirtualHost bilbo.csnet.uccs.edu:8888><VirtualHost bilbo.csnet.uccs.edu:8888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/customers/mpc/home/guest/sites/site.virtual/htdocs/customers

<VirtualHost salesbilbo.csnet.uccs.edu:8888><VirtualHost salesbilbo.csnet.uccs.edu:8888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen/mpc/home/guest/sites/site.virtual/htdocs/salesmen

<VirtualHost 128.198.192.172:8888><VirtualHost 128.198.192.172:8888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen/mpc/home/guest/sites/site.virtual/htdocs/salesmen

We can mix Name-based with IP-based virtual hosting.We can mix Name-based with IP-based virtual hosting.

Change “Change “IP-basedIP-based” to “” to “Mixed-basedMixed-based”. An error in config file.”. An error in config file.

NameVirtualHost 128.198.192.182:8888NameVirtualHost 128.198.192.182:8888

Port 8888Port 8888

<VirtualHost bilbo.csnet.uccs.edu:8888><VirtualHost bilbo.csnet.uccs.edu:8888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/customers/mpc/home/guest/sites/site.virtual/htdocs/customers

<VirtualHost salesbilbo.csnet.uccs.edu:8888><VirtualHost salesbilbo.csnet.uccs.edu:8888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen/mpc/home/guest/sites/site.virtual/htdocs/salesmen

<VirtualHost 128.198.192.172:8888><VirtualHost 128.198.192.172:8888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen/mpc/home/guest/sites/site.virtual/htdocs/salesmen

Page 21: Apache httpd Web Server C. Edward Chow. Advanced Internet & Web Systems chow2 Outline of the Talk Introduction to Apache httpd web server Basic Compilation,

Advanced Internet & Web Systems

chow 21

Port-based Virtual HostingPort-based Virtual HostingPort-based Virtual HostingPort-based Virtual HostingCan use one IP address to test many sites.Can use one IP address to test many sites.

Change IP-based to Port-based. An error in config file.Change IP-based to Port-based. An error in config file.

Different ports map to different sites.Different ports map to different sites.

User webuserUser webuser

Group webgroupGroup webgroup

Listen 7888Listen 7888

Listen 8888Listen 8888

<VirtualHost 128.198.192.182:7888><VirtualHost 128.198.192.182:7888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/customers/mpc/home/guest/sites/site.virtual/htdocs/customers

<VirtualHost 128.198.192.182:8888><VirtualHost 128.198.192.182:8888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen/mpc/home/guest/sites/site.virtual/htdocs/salesmen

Can use one IP address to test many sites.Can use one IP address to test many sites.

Change IP-based to Port-based. An error in config file.Change IP-based to Port-based. An error in config file.

Different ports map to different sites.Different ports map to different sites.

User webuserUser webuser

Group webgroupGroup webgroup

Listen 7888Listen 7888

Listen 8888Listen 8888

<VirtualHost 128.198.192.182:7888><VirtualHost 128.198.192.182:7888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/customers/mpc/home/guest/sites/site.virtual/htdocs/customers

<VirtualHost 128.198.192.182:8888><VirtualHost 128.198.192.182:8888>

DocumentRoot DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen/mpc/home/guest/sites/site.virtual/htdocs/salesmen