Download Apache and more Study notes Accounting in PDF only on Docsity!
Introduction to the Apache Web Server
Rich Bowen, Cooper McGregor, Inc
May 2, 2005
ii
- 1 History
- 1.1 Pre-history
- 1.1.1 As We May Think
- 1.1.2 WWW
- 1.1.3 NCSA
- 1.1.4 Netscape
- 1.2 Apache
- 1.3 The Apache Software Foundation
- 2 Installing
- 2.1 Section objectives
- 2.2 Building from source
- 2.3 Contents of distribution file, 1.3
- 2.4 Contents of distribution file, 2.0
- 2.5 Running configure
- 2.5.1 Building with mod perl
- 2.5.2 Other, more complex installs
- 2.5.3 Apache ToolBox
- 2.5.4 2.0
- 2.6 apxs
- 3 Starting and Stopping
- 3.1 Apache process architecture
- 3.1.1 Apache 1.3
- 3.1.2 Apache 2.0
- 3.2 apachectl
- 3.3 httpd
- 3.3.1 start
- 3.3.2 stop
- 3.3.3 Other options
- 3.4 Starting at boot
- 4 Configuration files
- 4.1 Introduction
- 4.2 The files
- 4.3 Config file syntax
- 4.3.1 Directives
- 4.3.2 Anatomy of directive docs
- 4.3.3 Comments
- 4.4 Sections
- 4.5 Options
- 4.6 Different config file
- 4.6.1 Running multiple apache daemons
- 4.7 GUI Configuration Tools
- 5 .htaccess files
- 5.1 Configuration
- 5.1.1 AccessFileName
- 5.1.2 AllowOverride
- 5.2 Performance
- 5.3 Exercise
- 6 Virtual Hosts
- 6.1 IP-based virtual hosts
- 6.2 Name-based virtual hosts
- 6.3 General caveats, comments
- 6.4 Exercise
- 6.5 Additional notes, examples, etc
- 6.5.1 /etc/hosts
- 6.5.2 Your example virtual host sections
- 6.5.3 #apache
- 6.5.4 mod vhost alias
- 7 MIME
- 7.1 HTTP headers
- 7.2 MIME configuration
- 7.2.1 AddType
- 7.2.2 RemoveType
- 7.2.3 DefaultType
- 7.2.4 ForceType
- 7.3 mod mime magic
- 7.4 Encoding
- 7.4.1 AddEncoding
- 7.4.2 RemoveEncoding
- 7.4.3 mod gzip
- 7.5 Language
- 7.6 Multiple file extensions
- 7.7 Experiment
- 8 URL Mapping
- 8.1 URL Mapping procedure
- 8.2 Location
- 8.3 Alias
- 8.4 ScriptAlias
- 8.5 AliasMatch and ScriptAliasMatch
- 8.6 Regular Expressions
- 8.7 Redirect
- 8.8 RedirectMatch
- 8.9 RedirectTemp and RedirectPermanent
- 8.10 DocumentRoot
- 8.11 Error documents
- 8.12 Error documents in Apache 2.0
- 8.13 Other modules that handler URL mapping
- 8.13.1 mod speling
- 8.13.2 mod rewrite
- 8.13.3 mod userdir and public html
- 9 Content Negotiation
- 9.1 Client configuration
- 9.1.1 Accept* headers
- 9.1.2 Quality factors
- 9.2 Negotiation Methods
- 9.2.1 MultiViews
- 9.2.2 Type map files
- 9.3 Caching
- 10 Indexing with mod autoindex
- 10.1 Options
- 10.2 DirectoryIndex
- 10.3 IndexOptions
- 10.4 Additional directives
- 10.4.1 HeaderName
- 10.4.2 ReadmeName
- 10.4.3 IndexIgnore
- 10.5 Searching and sorting
- 10.5.1 Apache 1.3
- 10.5.2 Apache 2.0
- 10.6 Security Concerns
- 11 Performance Tuning
- 11.1 Optimization, benchmarking and profiling
- 11.2 ab
- 11.3 Perl
- 11.4 Optimizing hardware
- 11.5 Tuning configuration settings
- 11.5.1 HostnameLookups
- 11.5.2 Symbolic links
- 11.5.3 .htaccess files
- 11.5.4 Negotiation
- 11.5.5 Caching and proxying
- 11.5.6 mod mmap static
- 11.6 Process Creation
- 11.6.1 MaxRequestsPerChild
- 11.7 KeepAlive
- 11.8 CGI/Other dynamic content
- 12 CGI programming
- 12.1 Introduction - The CGI
- 12.2 Apache configuration
- 12.3 How a CGI program works
- 12.4 Common problems
- 13 SSI
- 13.1 Configuration for SSI
- 13.2 XBitHack
- 13.3 mod include configuration directives
- 13.4 SSI directives
- 13.4.1 config
- 13.4.2 timefmt
- 13.4.3 echo
- 13.4.4 exec
- 13.4.5 fsize
- 13.4.6 flastmod
- 13.4.7 include
- 13.4.8 printenv
- 13.5 Variables and flow control
- 13.6 Security
- 14 Handlers and Filters
- 14.1 Handlers
- 14.1.1 Configuration directives
- 14.1.2 Standard handlers
- 14.1.3 Custom handlers
- 14.2 Filters
- 14.2.1 Chaining filters - CGI + SSI
- 14.2.2 mod deflate
- 15 mod perl
- 15.1 Overview - What is mod perl?
- 15.2 Installation
- 15.3 mod perl installation caveats
- 15.4 Configuration
- 15.5 Connecting to your database
- 15.6 CGI under mod perl
- 15.6.1 Apache::PerlRun
- 15.6.2 Apache::Registry
- 15.7 Apache handlers with mod perl
- 15.7.1 Installing a mod perl handler from CPAN
- 15.8 Writing a mod perl handler
- 15.8.1 Example mod perl handlers
- 15.8.2 Installing the example mod perl handler
- 15.8.3 Configuring the mod perl handler
- 15.9 Common problems
- 15.9.1 Don’t exit
- 15.9.2 Restart the server
- 15.9.3 Global values
- 15.10Other phases
- 15.10.1 PerlAccessHandler
- 15.10.2 PerlLogHandler
- 15.10.3 Perl configuration sections
- 15.11More information
- 16 Logging
- 16.1 Standard log files
- 16.2 Location and format of the log file
- 16.3 mod log io
- 16.4 Exercises
- 16.4.1 Error logs
- 16.4.2 LogLevel
- 16.5 Typical errors
- 16.5.1 Things to remember!
- 16.6 Logfile reporting
- 16.6.1 What your log file tells you
- 16.6.2 What your log file does not tell you
- 16.6.3 Log file parsing
- 16.7 Logging to a process
- 16.8 Logging to syslog
- 16.9 Rotating log files
- 16.9.1 Logfile::Rotate
- 16.9.2 rotatelogs
- 16.9.3 logresolve
- 16.10Logging for multiple virtual hosts
- 17 Authentication, Authorization, Access Control
- 17.1 Definitions
- 17.2 Basic Authentication
- 17.3 Configuration
- 17.4 FAQ
- 17.5 Basic Auth Caveats
- 17.6 Digest Auth
- 17.7 Configuration for Digest auth
- 17.8 Authentication against other things
- 17.8.1 mod auth db
- 17.8.2 mod auth mysql
- 17.9 Access Control
- 18 Spiders
- 18.1 Introduction
- 18.2 Potential problems
- 18.3 Spiders in the logs
- 18.4 Excluding spiders from your site
- 18.4.1 robots.txt
- 18.4.2 ROBOTS metatag
- 18.4.3 Yell at the operator
- 18.4.4 Block by address
- 18.4.5 Blocking with Deny from Env
- 18.5 Writing your own spider
- 19 Security
- 19.1 Overview
- 19.2 File permissions
- 19.2.1 Content directories
- 19.2.2 Library
- 19.2.3 bin
- 19.2.4 logs
- 19.2.5 proxy
- 19.2.6 public html
- 19.3 Configuration
- 19.3.1 ServerTokens
- 19.3.2 ServerTokens - hacking the source
- 19.3.3 ServerSignature
- 19.4 SSI
- 19.5 CGI
- 19.5.1 CGI exploit example - trusting form input
- 19.5.2 CGI exploit example - hidden form fields
- 19.6 Default file system settings
- 19.7 UserDir
- 19.8 Modules
- 19.9 suexec
- 19.10mod security
- 19.11mod dosevasive
- 20 SSL
- 20.1 Intro
- 20.2 Installing SSL
- 20.3 Certificates
- 20.4 Configuration
- 21 modules
- 21.1 Module list
- 21.1.1 Apache 1.3 modules:
- 21.1.2 Apache 2.0 modules:
- 21.1.3 What’s new, and what’s missing
- 21.2 mod access
- 21.3 mod actions
- 21.4 mod alias
- 21.5 mod asis
- 21.6 mod auth
- 21.7 mod auth anon
- 21.8 mod auth db
- 21.9 mod auth dbm
- 21.10mod auth digest
- 21.11mod autoindex
- 21.12mod cern meta
- 21.13mod cgi
- 21.14mod digest
- 21.15mod dir
- 21.16mod env
- 21.17mod example
- 21.18mod expires
- 21.19mod headers
- 21.20mod imap
- 21.21mod include
- 21.22mod info
- 21.23mod log agent
- 21.24mod log config
- 21.25mod log referer
- 21.26mod mime
- 21.27mod mime magic
- 21.28mod mmap static
- 21.29mod negotiation
- 21.30mod proxy
- 21.31mod rewrite
- 21.32mod setenvif
- 21.33mod so
- 21.34mod speling
- 21.35mod status
- 21.36mod unique id
- 21.37mod usertrack
- 21.38mod vhost alias
- 22 WebDAV
- 22.1 mod dav on 1.3
- 22.2 mod dav on 2.0
- 22.3 DAV clients
- 23 mod proxy
- 23.1 Caching
- 23.2 Proxying
- 23.3 Rewrite and proxying
- 23.4 mod proxy html
- 23.5 General comments
He wrote the CERN web server, and the www client software, terming it a “browser”.
1.1.3 NCSA
In 1992 or thereabouts, a project started at NCSA (The National Center for Supercomputing Activities) at UIUC (University of Illinois at Urbana-Champaign to develop a graphical web browser, which was code- named “Mosaic”, although the name “Mozilla” was also used. As part of that project, the NCSA HTTPd was also written. Mosaic was not the first graphical web browser, as has sometimes been claimed since then, but it quickly became the most popular. You can read more about this at http://www.webhistory.org/www.lists/www-talk.1993q1/0262.html Rob McCool was the primary author of the NCSA NTTPd code, and his name still appears in the default httpd.conf file.
1.1.4 Netscape
In 1995, Mosaic Communications, quickly renamed to Netscape Communications, was founded taking most of the programming talent from the NCSA HTTPd project This left a void for those web sites which were running the NCSA software, particularly in a growing economy where people had come to rely on their web sites.
1.2 Apache
The Apache project was started simply as a place to collect patches for the NCSA HTTPd. The original “Apache Group” consisted of 8 guys who wanted to add functionality to, and fix problems with, the existing HTTPd code.
- Brian Behlendorf
- Roy T. Fielding
- Rob Hartill
- David Robinson
- Cliff Skolnick
- Randy Terbush
- Robert S. Thau
- Andrew Wilson 2
The name “Apache” was, apparently, picked by Ben Laurie out of respect for the Apache people.^1 The other form of this story is that Apache is simply another way of saying that it was “A Patchy” server. See also http://httpd.apache.org/ABOUT_APACHE.html and http://www.geocrawler.com/mail/thread.php3?subject=name&list= Randy Terbush wrote the Apache Software License, based on the BSD Software License, ensuring that the software will be free and open.
- C2.net donates server space for Apache.org
- April 1995 - Apache 0.6.2 released
- December 1995 - Apache 1.0, a complete rewrite, released.
- Main advance here is modularization of code.
- Project codenamed ”Shambala”
- Robert Thau main developer of this code
- Same basic code base in use today in 1.3.x
- 1997 - Open/Free software goes mainstream
- 1997 - The Cathedral and The Bazaar
- Apache deal with IBM - Apache forms codebase for WebSphere
- Apache Software Foundation formed
- Revision of License to be more palatable to IBM - Advertising clause removed
- 1997 - Apache 1.3 released, with Windows support
- May 2000 - Apachecon Orlando - Apache 2.0 alpha released
- October 2000 - ApacheCon Europe - Douglas Adams speaks, one of his final speaking ops before he suddenly died.
- April 2001 - ApacheCon Santa Clara - Apache 2.0 initial beta release
- April 2002 - Apache 2.0.35 releases as GA (General Availability). 2.0.36 follows shortly after with some important fixes.
- May 2002 - Apache 1.3 enters maintenance mode (No new features, just bug fixes and documentation updates).
- http://uptime.netcraft.com/up/today/top.avg.html
1.3 The Apache Software Foundation
The ASF was formed for a number of reasons. The catalyst was the IBM deal, and their desire to deal with an actual legal entity. However, the impact of creating the ASF was rather larger than that. The goals of the ASF are: (^1) I recommend reading Chasing Shadows by Shelley Ann Bowen Hatfieid (no relation) about the Apache people. http://www.amazon.com/exec/obidos/asin/ 3
Section 2
Installing
http://httpd.apache.org/docs/install.html
2.1 Section objectives
In this section, the students will each have to install Apache themselves. They should each have a server system which does not have Apache installed. They should download the Apache source, verify the pgp signature and MD5 sum, unpack and install from source. They should experiment with the arguments to ./configure and should install Apache with and without DSO support. If the machines are reasonably fast, they should try multiple installations, and see what happens. Students should install Apache 1.3 and Apache 2.0, and should verify that both are functioning correctly, at the same time, running on different ports. Students should then reinstall Apache 1.3 using Apache ToolBox, enabling any modules which you wish to use in the remainder of the course. In particular, you will probably want to enable mod ssl, mod perl, and mod php. Make sure that Apache 2 is installed with DAV and dav-fs enabled.
2.2 Building from source
Although many Unixes come with some version of Apache preinstalled, there are many arguments for in- stalling the server yourself.
- Exactly the way you need it
- Optimized for your hardware
- Ensure nothing strange added
- Directory structure that makes sense to you 5
This is a good point to encourage discussion of package management systems, particularly if your students are already fond of a particular unix distribution that is tied to a package management system. The arguments for installing from source seem rather weak when weighed against the convenience of a package management system. However, there are times when it is necessary to install from source, and so it is useful to know how to do it. Get source from http://httpd.apache.org Latest releases are 1.3.33 and 2.0.52. 2.1 is in development, and there is not yet a downloadable packaged version of it. The site is mirrored around the world, and downloading Apache from a mirror site is of great benefit to the ASF, financially. Our monthly bandwidth bill is astronomical. Next, you really need to verify the distribution using the MD5 sum, and, if possible, the PGP signature that are available from the site. However, you should get these from the official Apache site, rather than the mirror site. The rationale here is that if the distro was compromised, the signature files probably were also. Verify the distribution There are two ways to verify the distribution. The MD5 sum can be used as follows:
md5sum httpd 2.0.52.tar.gz
Verify that the output of that command matches the contents of the .md5 file. Note that the md5sum utility is just called md5 on some Unixes. To verify the pgp signature, you will need to first import the keyring from the Apache site: Download http://www.apache.org/dist/httpd/KEYS:
wget http://www.apache.org/dist/httpd/KEYS gpg --import KEYS
You can use curl or GET, if you have one of those installed. The GET utility gets installed when you install the LWP suite of modules for Perl. Finally, verify the signature with:
gpg --verify httpd_2.0.52.tar.gz.asc
Unpack the distribution tar -vzxf httpd-2.0.52.tar.gz
6