SlideShare une entreprise Scribd logo
1  sur  24
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.

4/2/2010               C. Edward Chow          CS401 Page 1
Web Server Installation Statistics
• http://www.netcraft.co.uk/survey/




4/2/2010               C. Edward Chow   CS401 Page 2
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 --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.


4/2/2010               C. Edward Chow           CS401 Page 3
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 # = 8<last 3 digits of SS#>
  Add “Port 8<last 3 digits of SS#>“ to httpd.conf.

4/2/2010               C. Edward Chow           CS401 Page 4
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



  4/2/2010                    C. Edward Chow                CS401 Page 5
Apache Testbed: LAN Setup
• /usr/www/lan_setup script for bilbo:
   ifconfig eth0 128.198.192.182
   ifconfig eth0:0 128.198.192.172
   ifconfig eth0:1 128.198.192.202
• Or on linuxconf for bilbo, select
  config | 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).


4/2/2010                    C. Edward Chow                CS401 Page 6
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.




4/2/2010               C. Edward Chow          CS401 Page 7
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


4/2/2010                    C. Edward Chow               CS401 Page 8
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:57 1998] Server configured -- resuming normal operations or
  webuser 13013 0.0 2.2 1260 704 ? 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:16 -0700] "GET / HTTP/1.0" 200 170
• Use a browser (on vinci or other machines) to access
  the server a few times with url = http://bilbo:8345/
• “kill `cat <site>/logs/httpd.pid`” to terminate web server.
  note that it is back quote ` and not „

  4/2/2010                       C. Edward Chow                    CS401 Page 9
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

4/2/2010                     C. Edward Chow            CS401 Page 10
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 “~”

4/2/2010                C. Edward Chow            CS401 Page 11
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:email 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)
   4/2/2010                      C. Edward Chow                   CS401 Page 12
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.
4/2/2010                   C. Edward Chow              CS401 Page 13
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
  http://bilbo.uccs.edu:<portno>/ or
   http://frodo.uccs.edu:<portno>/ depending which machine
• Check the access_log file. Keep them as record
4/2/2010                   C. Edward Chow              CS401 Page 14
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




4/2/2010             C. Edward Chow         CS401 Page 15
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.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
4/2/2010                  C. Edward Chow             CS401 Page 16
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.

4/2/2010                C. Edward Chow          CS401 Page 17
Site.Virtual/Name-based
• cd /mpc/home/<login>/sites/site.virtual/Name-based
• edit the httpd.conf in conf directory:
• NameVirtualHost 192.168.123.2 
  NameVirtualHost 128.198.192.182
  Port 8<last 3 digits of SS#>
• <VirtualHost www.butterthlies.com> 
  <VirtualHost bilbo.uccs.edu:portno>
  Here portno is 8<last 3 digits of your SS#>
• ServerAdmin sales@butterthlies.com 
  ServerAdmin <login>@cs.uccs.edu
• /usr/www  /mpc/home/<login>/sites/
• <VirtualHost sales.butterthlies.com> 
  <VirtualHost sales-bilbo.uccs.edu:portno>
• Go to start virtual hositng.

4/2/2010                  C. Edward Chow               CS401 Page 18
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 192.168.123.2> 
  <VirtualHost 128.198.192.182:portno>
  Here portno is 8<last 3 digits of your SS#>
• ServerName bilbo.uccs.edu
• ServerAdmin sales@butterthlies.com 
  ServerAdmin <login>@cs.uccs.edu
• /usr/www  /mpc/home/<login>/sites/
• <VirtualHost 192.168.123.3> 
  <VirtualHost 128.198.192.172:portno>
• ServerName b2b.uccs.edu

4/2/2010                  C. Edward Chow             CS401 Page 19
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.182: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 128.198.192.172:8888>
DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen


4/2/2010                  C. Edward Chow             CS401 Page 20
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 128.198.192.182:7888>
DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/customers
<VirtualHost 128.198.192.182:8888>
DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen

4/2/2010                  C. Edward Chow             CS401 Page 21
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.

4/2/2010                C. Edward Chow          CS401 Page 22
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.




4/2/2010              C. Edward Chow          CS401 Page 23
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.




4/2/2010              C. Edward Chow          CS401 Page 24

Contenu connexe

Tendances

Apache web server
Apache web serverApache web server
Apache web serverzrstoppe
 
Apache Presentation
Apache PresentationApache Presentation
Apache PresentationAnkush Jain
 
Apache Tutorial
Apache TutorialApache Tutorial
Apache TutorialGuru99
 
Apache web server tutorial for linux
Apache web server tutorial for linuxApache web server tutorial for linux
Apache web server tutorial for linuxSahad Sali
 
Linux Webserver Installation Command and GUI.ppt
Linux Webserver Installation Command and GUI.pptLinux Webserver Installation Command and GUI.ppt
Linux Webserver Installation Command and GUI.pptwebhostingguy
 
httpd — Apache Web Server
httpd — Apache Web Serverhttpd — Apache Web Server
httpd — Apache Web Serverwebhostingguy
 
Securing the Apache web server
Securing the Apache web serverSecuring the Apache web server
Securing the Apache web serverwebhostingguy
 
APACHE WEB SERVER FOR LINUX
APACHE WEB SERVER FOR LINUXAPACHE WEB SERVER FOR LINUX
APACHE WEB SERVER FOR LINUXwebhostingguy
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning InfrastructurePerforce
 
WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.pptwebhostingguy
 
Apache installation and configurations
Apache installation and configurationsApache installation and configurations
Apache installation and configurationsNikhil Jain
 
Performance all teh things
Performance all teh thingsPerformance all teh things
Performance all teh thingsMarcus Deglos
 
Ch 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet ServersCh 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet Serverswebhostingguy
 
Lesson 9. The Apache Web Server
Lesson 9. The Apache Web ServerLesson 9. The Apache Web Server
Lesson 9. The Apache Web Serverwebhostingguy
 

Tendances (20)

Apache web server
Apache web serverApache web server
Apache web server
 
Apache Presentation
Apache PresentationApache Presentation
Apache Presentation
 
Apache Tutorial
Apache TutorialApache Tutorial
Apache Tutorial
 
Apache web server tutorial for linux
Apache web server tutorial for linuxApache web server tutorial for linux
Apache web server tutorial for linux
 
Apache Web Server Setup 1
Apache Web Server Setup 1Apache Web Server Setup 1
Apache Web Server Setup 1
 
Apache Web Server Setup 4
Apache Web Server Setup 4Apache Web Server Setup 4
Apache Web Server Setup 4
 
Linux Webserver Installation Command and GUI.ppt
Linux Webserver Installation Command and GUI.pptLinux Webserver Installation Command and GUI.ppt
Linux Webserver Installation Command and GUI.ppt
 
httpd — Apache Web Server
httpd — Apache Web Serverhttpd — Apache Web Server
httpd — Apache Web Server
 
Securing the Apache web server
Securing the Apache web serverSecuring the Apache web server
Securing the Apache web server
 
APACHE WEB SERVER FOR LINUX
APACHE WEB SERVER FOR LINUXAPACHE WEB SERVER FOR LINUX
APACHE WEB SERVER FOR LINUX
 
Apache ppt
Apache pptApache ppt
Apache ppt
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
Apache HTTP Server
Apache HTTP ServerApache HTTP Server
Apache HTTP Server
 
are available here
are available hereare available here
are available here
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure
 
WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.ppt
 
Apache installation and configurations
Apache installation and configurationsApache installation and configurations
Apache installation and configurations
 
Performance all teh things
Performance all teh thingsPerformance all teh things
Performance all teh things
 
Ch 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet ServersCh 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet Servers
 
Lesson 9. The Apache Web Server
Lesson 9. The Apache Web ServerLesson 9. The Apache Web Server
Lesson 9. The Apache Web Server
 

En vedette (7)

Apache server configuration
Apache server configurationApache server configuration
Apache server configuration
 
Network Sockets
Network SocketsNetwork Sockets
Network Sockets
 
Ppt of socket
Ppt of socketPpt of socket
Ppt of socket
 
TCP Vs UDP
TCP Vs UDP TCP Vs UDP
TCP Vs UDP
 
Ports & sockets
Ports  & sockets Ports  & sockets
Ports & sockets
 
UDP - User Datagram Protocol
UDP - User Datagram ProtocolUDP - User Datagram Protocol
UDP - User Datagram Protocol
 
Tcp and udp
Tcp and udpTcp and udp
Tcp and udp
 

Similaire à Apache web server installation/configuration, Virtual Hosting

Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Rich Bowen
 
Securing Apache Web Servers
Securing Apache Web ServersSecuring Apache Web Servers
Securing Apache Web Serverswebhostingguy
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2Vincent Mercier
 
17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]Krisman Tarigan
 
Apache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheApache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheWildan Maulana
 
Deployment ibm connections - No Http Server required
Deployment ibm connections - No Http Server requiredDeployment ibm connections - No Http Server required
Deployment ibm connections - No Http Server requiredSarwar Javaid
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Ben Hall
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisationgrooverdan
 
Utosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptUtosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptwebhostingguy
 
Utosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptUtosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptwebhostingguy
 
Utosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptUtosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptwebhostingguy
 

Similaire à Apache web server installation/configuration, Virtual Hosting (20)

Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
 
Apache
ApacheApache
Apache
 
Apache
ApacheApache
Apache
 
Apache
ApacheApache
Apache
 
Apache1.ppt
Apache1.pptApache1.ppt
Apache1.ppt
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
Http
HttpHttp
Http
 
Securing Apache Web Servers
Securing Apache Web ServersSecuring Apache Web Servers
Securing Apache Web Servers
 
Securing Apache Web Servers
Securing Apache Web ServersSecuring Apache Web Servers
Securing Apache Web Servers
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2
 
17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]
 
Apache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheApache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With Apache
 
Deployment ibm connections - No Http Server required
Deployment ibm connections - No Http Server requiredDeployment ibm connections - No Http Server required
Deployment ibm connections - No Http Server required
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
Clug 2011 March web server optimisation
Clug 2011 March  web server optimisationClug 2011 March  web server optimisation
Clug 2011 March web server optimisation
 
Utosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptUtosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.ppt
 
Utosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptUtosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.ppt
 
Utosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.pptUtosc2007_Apache_Configuration.ppt
Utosc2007_Apache_Configuration.ppt
 
Team lab install_en
Team lab install_enTeam lab install_en
Team lab install_en
 
Apache1.ppt
Apache1.pptApache1.ppt
Apache1.ppt
 

Plus de webhostingguy

Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Frameworkwebhostingguy
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guidewebhostingguy
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3webhostingguy
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serverswebhostingguy
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidationwebhostingguy
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreementwebhostingguy
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...webhostingguy
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructurewebhostingguy
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.pptwebhostingguy
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy webhostingguy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandiserswebhostingguy
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Productswebhostingguy
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mbwebhostingguy
 

Plus de webhostingguy (20)

File Upload
File UploadFile Upload
File Upload
 
Running and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test FrameworkRunning and Developing Tests with the Apache::Test Framework
Running and Developing Tests with the Apache::Test Framework
 
MySQL and memcached Guide
MySQL and memcached GuideMySQL and memcached Guide
MySQL and memcached Guide
 
Novell® iChain® 2.3
Novell® iChain® 2.3Novell® iChain® 2.3
Novell® iChain® 2.3
 
Load-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web serversLoad-balancing web servers Load-balancing web servers
Load-balancing web servers Load-balancing web servers
 
SQL Server 2008 Consolidation
SQL Server 2008 ConsolidationSQL Server 2008 Consolidation
SQL Server 2008 Consolidation
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
What is mod_perl?
What is mod_perl?What is mod_perl?
What is mod_perl?
 
Master Service Agreement
Master Service AgreementMaster Service Agreement
Master Service Agreement
 
Notes8
Notes8Notes8
Notes8
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...Dell Reference Architecture Guide Deploying Microsoft® SQL ...
Dell Reference Architecture Guide Deploying Microsoft® SQL ...
 
Managing Diverse IT Infrastructure
Managing Diverse IT InfrastructureManaging Diverse IT Infrastructure
Managing Diverse IT Infrastructure
 
Web design for business.ppt
Web design for business.pptWeb design for business.ppt
Web design for business.ppt
 
IT Power Management Strategy
IT Power Management Strategy IT Power Management Strategy
IT Power Management Strategy
 
Excel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for MerchandisersExcel and SQL Quick Tricks for Merchandisers
Excel and SQL Quick Tricks for Merchandisers
 
OLUG_xen.ppt
OLUG_xen.pptOLUG_xen.ppt
OLUG_xen.ppt
 
Parallels Hosting Products
Parallels Hosting ProductsParallels Hosting Products
Parallels Hosting Products
 
Microsoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 MbMicrosoft PowerPoint presentation 2.175 Mb
Microsoft PowerPoint presentation 2.175 Mb
 
Reseller's Guide
Reseller's GuideReseller's Guide
Reseller's Guide
 

Apache web server installation/configuration, Virtual Hosting

  • 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. 4/2/2010 C. Edward Chow CS401 Page 1
  • 2. Web Server Installation Statistics • http://www.netcraft.co.uk/survey/ 4/2/2010 C. Edward Chow CS401 Page 2
  • 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 --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. 4/2/2010 C. Edward Chow CS401 Page 3
  • 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 # = 8<last 3 digits of SS#> Add “Port 8<last 3 digits of SS#>“ to httpd.conf. 4/2/2010 C. Edward Chow CS401 Page 4
  • 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 4/2/2010 C. Edward Chow CS401 Page 5
  • 6. Apache Testbed: LAN Setup • /usr/www/lan_setup script for bilbo: ifconfig eth0 128.198.192.182 ifconfig eth0:0 128.198.192.172 ifconfig eth0:1 128.198.192.202 • Or on linuxconf for bilbo, select config | 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). 4/2/2010 C. Edward Chow CS401 Page 6
  • 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. 4/2/2010 C. Edward Chow CS401 Page 7
  • 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 4/2/2010 C. Edward Chow CS401 Page 8
  • 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:57 1998] Server configured -- resuming normal operations or webuser 13013 0.0 2.2 1260 704 ? 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:16 -0700] "GET / HTTP/1.0" 200 170 • Use a browser (on vinci or other machines) to access the server a few times with url = http://bilbo:8345/ • “kill `cat <site>/logs/httpd.pid`” to terminate web server. note that it is back quote ` and not „ 4/2/2010 C. Edward Chow CS401 Page 9
  • 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 4/2/2010 C. Edward Chow CS401 Page 10
  • 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 “~” 4/2/2010 C. Edward Chow CS401 Page 11
  • 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:email 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) 4/2/2010 C. Edward Chow CS401 Page 12
  • 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. 4/2/2010 C. Edward Chow CS401 Page 13
  • 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 http://bilbo.uccs.edu:<portno>/ or http://frodo.uccs.edu:<portno>/ depending which machine • Check the access_log file. Keep them as record 4/2/2010 C. Edward Chow CS401 Page 14
  • 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 4/2/2010 C. Edward Chow CS401 Page 15
  • 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.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 4/2/2010 C. Edward Chow CS401 Page 16
  • 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. 4/2/2010 C. Edward Chow CS401 Page 17
  • 18. Site.Virtual/Name-based • cd /mpc/home/<login>/sites/site.virtual/Name-based • edit the httpd.conf in conf directory: • NameVirtualHost 192.168.123.2  NameVirtualHost 128.198.192.182 Port 8<last 3 digits of SS#> • <VirtualHost www.butterthlies.com>  <VirtualHost bilbo.uccs.edu:portno> Here portno is 8<last 3 digits of your SS#> • ServerAdmin sales@butterthlies.com  ServerAdmin <login>@cs.uccs.edu • /usr/www  /mpc/home/<login>/sites/ • <VirtualHost sales.butterthlies.com>  <VirtualHost sales-bilbo.uccs.edu:portno> • Go to start virtual hositng. 4/2/2010 C. Edward Chow CS401 Page 18
  • 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 192.168.123.2>  <VirtualHost 128.198.192.182:portno> Here portno is 8<last 3 digits of your SS#> • ServerName bilbo.uccs.edu • ServerAdmin sales@butterthlies.com  ServerAdmin <login>@cs.uccs.edu • /usr/www  /mpc/home/<login>/sites/ • <VirtualHost 192.168.123.3>  <VirtualHost 128.198.192.172:portno> • ServerName b2b.uccs.edu 4/2/2010 C. Edward Chow CS401 Page 19
  • 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.182: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 128.198.192.172:8888> DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen 4/2/2010 C. Edward Chow CS401 Page 20
  • 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 128.198.192.182:7888> DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/customers <VirtualHost 128.198.192.182:8888> DocumentRoot /mpc/home/guest/sites/site.virtual/htdocs/salesmen 4/2/2010 C. Edward Chow CS401 Page 21
  • 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. 4/2/2010 C. Edward Chow CS401 Page 22
  • 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. 4/2/2010 C. Edward Chow CS401 Page 23
  • 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. 4/2/2010 C. Edward Chow CS401 Page 24