ebook img

Sams Teach Yourself Apache 2 in 24 Hours PDF

490 Pages·2002·3.6 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Sams Teach Yourself Apache 2 in 24 Hours

00 0672323559 FM 5/22/02 10:28 AM Page i Daniel López Ridruejo Ian Kallen Teach Yourself Apache 2 24 in Hours 800 East 96th St.,Indianapolis,Indiana,4624 0 USA 00 0672323559 FM 5/22/02 10:28 AM Page ii Sams Teach Yourself Apache 2 ACQUISITIONSEDITOR Shelley Johnston in 24 Hours DEVELOPMENTEDITOR Copyright © 2002 by Sams Publishing Heather Goodell All rights reserved. No part of this book shall be reproduced,stored in a MANAGINGEDITOR retrieval system,or transmitted by any means,electronic,mechanical,photo- Charlotte Clapp copying,recording,or otherwise,without written permission from the pub- PROJECTEDITOR lisher. No patent liability is assumed with respect to the use of the information Elizabeth Finney contained herein. Although every precaution has been taken in the preparation of this book,the publisher and author assume no responsibility for errors or COPYEDITOR omissions. Nor is any liability assumed for damages resulting from the use of Michael Henry the information contained herein. INDEXER International Standard Book Number:0-67232-355-9 Mandie Frank Library of Congress Catalog Card Number:2001096489 PROOFREADER Bob LaRoche Printed in the United States of America TECHNICALEDITOR First Printing:June 2002 Patrik Grip-Jansson 05 04 03 02 4 3 2 1 Allan Liska Trademarks TEAMCOORDINATOR Amy Patton All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the INTERIORDESIGNER accuracy of this information. Use of a term in this book should not be regarded Gary Adair as affecting the validity of any trademark or service mark. COVERDESIGNER Aren Howell Warning and Disclaimer PAGELAYOUT Every effort has been made to make this book as complete and as accurate as Susan Geiselman possible,but no warranty or fitness is implied. The information provided is on an “as is”basis. The author(s) and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages aris- ing from the information contained in this book. 00 0672323559 FM 5/22/02 10:28 AM Page iii Contents at a Glance Foreword xx Introduction 1 PART I Basic Apache 5 Hour 1 Apache and the Web 7 2 Understanding Apache Internals 23 3 Installing and Building Apache 37 4 Getting Started with Apache 53 5 Using Apache to Serve Static Conten 71 6 Serving Dynamic Content with CGI 87 7 Restricting Access 107 8 Logging and Monitoring 125 9 Content Negotiation and Environment Variables 143 10 Apache GUIs 155 PART II Advanced Apache 171 Hour 11 Multi-Processing Modules 173 12 Filtering Modules 189 13 Publishing Extensions 203 14 Virtual Hosting 217 15 Apache as a Proxy Server 233 16 Tuning Apache 249 17 Setting Up a Secure Server 263 PART III Extending Apache 283 Hour 18 Extending Apache 285 19 PHP 301 20 mod_perl 323 21 Tomcat and Apache 347 22 Dynamic URI Resolution with mod_rewrite 371 23 Migrating to Apache 2.0 387 00 0672323559 FM 5/22/02 10:28 AM Page iv 24 Additional Apache Modules and Projects 399 A The Apache Software License 411 Index 413 00 0672323559 FM 5/22/02 10:28 AM Page v Contents Introduction 1 PART I Basic Apache 5 HOUR 1 Apache and the Web 7 Internet Protocols ....................................................................................................7 TCP/IP ..............................................................................................................8 DNS ..................................................................................................................9 HTTP ..............................................................................................................10 URL ................................................................................................................10 SSL ..................................................................................................................11 HTTP Internals ....................................................................................................11 Do It Yourself HTTP ............................................................................................14 Web Servers History ............................................................................................15 How It All Got Started ....................................................................................15 Apache ............................................................................................................16 Apache Software Foundation ..........................................................................17 Apache Considerations ........................................................................................17 Advantages of Apache ....................................................................................17 Disadvantages ..................................................................................................20 Summary ..............................................................................................................21 Q&A ......................................................................................................................21 Further Reading ....................................................................................................22 HOUR 2 Understanding Apache Internals 23 Evolution of the Web ............................................................................................23 Apache Architecture ............................................................................................24 Multi-Processing Modules ..............................................................................25 Additional MPMs ............................................................................................27 MPM Selection and Compatibility ..................................................................27 Hooks ....................................................................................................................28 Multi-Protocol Support ........................................................................................28 Content-Handling Modules ..................................................................................29 Connector Modules ..............................................................................................29 Filters ....................................................................................................................30 Access/Authentication/Authorization Modules ....................................................30 Apache Portable Runtime ....................................................................................31 00 0672323559 FM 5/22/02 10:28 AM Page vi vi Sams Teach Yourself Apache 2 in 24 Hours A Day in the Life of a Request ............................................................................32 Apache Startup ................................................................................................33 Request Process ..............................................................................................33 Checking for Hooks ........................................................................................33 Summary ..............................................................................................................34 Q&A ......................................................................................................................34 Quiz ......................................................................................................................35 Quiz Answers ........................................................................................................35 Further Reading ....................................................................................................35 HOUR 3 Installing and Building Apache 37 Choosing the Appropriate Installation Method ....................................................37 Building from Source ......................................................................................38 Installing a Binary ..........................................................................................38 Apache Version Naming ..................................................................................38 Installing Apache on Unix ....................................................................................39 Checking Whether Apache Is Already Installed in Your System ....................39 Installing from Source ....................................................................................40 Installing Binaries ............................................................................................43 Building from CVS ........................................................................................44 Installing Apache on Windows ............................................................................45 Notes About the Windows Installer ................................................................48 Verifying the Integrity of Downloaded Software ................................................48 Commercial Alternatives ......................................................................................48 Summary ..............................................................................................................49 Q&A ......................................................................................................................49 Quiz ......................................................................................................................50 Quiz Answers ........................................................................................................50 Further Reading ....................................................................................................50 HOUR 4 Getting Started with Apache 53 Layout of Server Files and Directories ................................................................53 Apache Binary and Support Scripts ................................................................54 Log Files ..........................................................................................................54 Configuration Files ..........................................................................................54 CGI Scripts Location ......................................................................................55 Build Information and Header Files ................................................................55 Error Messages ................................................................................................55 Manual Pages ..................................................................................................55 Modules and Libraries Directory ....................................................................55 Web Pages and Images ....................................................................................55 Installation Differences ..................................................................................55 00 0672323559 FM 5/22/02 10:28 AM Page vii Contents vii Configuration Files Structure ..............................................................................56 Directives ........................................................................................................56 Containers ........................................................................................................58 Conditional Evaluation ....................................................................................59 ServerRoot ..................................................................................................60 Including Additional Configuration Files ......................................................60 Per-Directory Configuration Files ..................................................................60 Merging Rules ................................................................................................61 Additional Configuration Files ........................................................................62 Minimal Apache Configuration ......................................................................62 Log Files ..............................................................................................................63 access_log....................................................................................................63 error_log ......................................................................................................63 Additional Files ..............................................................................................64 Apache-Related Commands ................................................................................64 Apache Server Binary ....................................................................................64 Controlling Apache on Windows ....................................................................65 Apache Control Script ....................................................................................66 Starting Apache for the First Time ......................................................................66 Troubleshooting ....................................................................................................67 Already Existing Web Server ..........................................................................67 No Permission to Bind to Port ........................................................................68 Access Denied ................................................................................................68 Wrong Group Settings ....................................................................................68 Summary ..............................................................................................................68 Q&A ......................................................................................................................69 Quiz ......................................................................................................................69 Quiz Answers ........................................................................................................69 Related Directives ................................................................................................69 Further Reading ....................................................................................................70 HOUR 5 Using Apache to Serve Static Content 71 Addresses,Ports,and Server Names ....................................................................71 TheServerNameDirective ..................................................................................72 Customizing the Web Server ................................................................................73 Error Messages ................................................................................................73 Customizing Server Information ....................................................................75 Aliasing and Mapping of Resources ....................................................................76 URL Redirection ..................................................................................................77 MIME Types ........................................................................................................78 Defining MIME Types ....................................................................................78 MIME Magic ..................................................................................................79 TheForceTypeDirective ..............................................................................79 00 0672323559 FM 5/22/02 10:28 AM Page viii viii Sams Teach Yourself Apache 2 in 24 Hours Content Handlers ..................................................................................................80 Directory Listings ................................................................................................80 Default Document Index ................................................................................80 Directory Indexing ..........................................................................................81 Forbidding Directory Access ..........................................................................82 Trailing Slash ..................................................................................................82 Icons for Bookmarks ............................................................................................83 Summary ..............................................................................................................83 Q&A ......................................................................................................................84 Quiz ......................................................................................................................84 Quiz Answers ........................................................................................................84 Related Directives ................................................................................................84 Listening and Hostname ..................................................................................84 Customization ..................................................................................................85 Site Structure ..................................................................................................85 Directory Listings ............................................................................................85 MIME and File Handlers ................................................................................85 Further Reading ....................................................................................................85 HOUR 6 Serving Dynamic Content with CGI 87 Common Gateway Interface ................................................................................87 CGI Protocol ....................................................................................................88 CGI Operation ................................................................................................88 CGI Environment Variables ............................................................................88 CGI Response ..................................................................................................89 Advantages and Disadvantages of CGI Scripts ....................................................89 Portability ........................................................................................................89 Simplicity ........................................................................................................90 Existing Code ..................................................................................................90 Source Hiding ..................................................................................................90 Memory Leaks ................................................................................................90 Performance ....................................................................................................90 Code and Presentation ....................................................................................91 Configuring Apache ..............................................................................................91 CGI Content ....................................................................................................91 CGI Security ....................................................................................................93 Non Parse Headers (NPH) Scripts ..................................................................94 Debugging CGI Execution ..............................................................................94 Unix Configuration ..............................................................................................94 Testing Shell Script CGIs ................................................................................94 Perl Installation ................................................................................................95 Testing Perl CGI Scripts ..................................................................................96 00 0672323559 FM 5/22/02 10:28 AM Page ix Contents ix Windows Configuration ........................................................................................97 Testing Batch File CGIs ..................................................................................97 Perl on Windows ............................................................................................97 Enhancing Your CGI Performance ....................................................................100 mod_perl ....................................................................................................100 FastCGI ..........................................................................................................100 Common CGI Problems ....................................................................................101 Forbidden Error ............................................................................................101 Internal Server Error ......................................................................................101 Source Code in the Browser ..........................................................................103 Summary ............................................................................................................103 Q&A ....................................................................................................................103 Quiz ....................................................................................................................104 Quiz Answers ......................................................................................................104 Related Directives ..............................................................................................104 Associating Resources as CGI ......................................................................104 Debugging and mod_cgid ..........................................................................104 Further Reading ..................................................................................................105 HOUR 7 Restricting Access 107 Authentication ....................................................................................................107 Client Authentication ..........................................................................................108 User Management ..........................................................................................109 Apache Authentication Modules ........................................................................109 Common Functionality ..................................................................................109 Module Functionality ....................................................................................110 File-Based Authentication ............................................................................111 Database File-Based Access Control ............................................................113 Digest-Based Authentication ........................................................................114 Additional Authentication Modules ..............................................................116 Access Control ....................................................................................................116 Access Rules ..................................................................................................116 Access Rules Evaluation ..............................................................................117 Combining Access Methods ..............................................................................119 Limiting Access Based on HTTP Methods ........................................................119 Summary ............................................................................................................120 Q&A ....................................................................................................................120 Quiz ....................................................................................................................121 Quiz Answers ......................................................................................................121 Related Directives ..............................................................................................122 Common Authentication ................................................................................122 File-Based Authentication ............................................................................122

Description:
Sams Teach Yourself Apache in 24 Hours covers the installation, configuration, and ongoing administration of the Apache Web server, the most popular Internet Web server. It covers both the 1.3 and the new 2.0 versions of Apache. Using a hands-on, task-oriented format, it concentrates on the most pop
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.