Apache2 BootCamp : Using Apache to Serve Static Content

Preview:

Citation preview

Day #2Using Apache to Serve Static Content

Wildan Maulanawildan.m@openthinklabs.com

http://workshop.openthinklabs.com

#5

Overview

● How to configure Apache to listen on different IP addresses and ports

● How to organize the URL space with directory aliasing and redirection

● How to customize the server information and error messages

Customizing the Web Server

● Error Messages● International Error Messages● Handling URL Errors: mod_speling

● Customizing Server Information● Server Identification● Contact Information

Customizing the Web ServerError Messages

ErrorDocument

ErrorDocument 500 http://foo.example.com/cgi-bin/testerErrorDocument 404 /cgi-bin/bad_urls.plErrorDocument 401 /subscription_info.htmlErrorDocument 403 "Sorry can't allow you access today"

Customizing the Web ServerInternational Error Messages

Server Side Includes (mod_include) and content negotiation (mod_negotiation).

Custom Error Codes

Customizing the Web ServerHandling URL Errors: mod_speling

CheckSpelling

Customizing the Web ServerServer Identification & Contact Information

ServerTokens Options

Settings Output

ServerTokens ProductOnly Apache

ServerTokens Minimal Apache/2.0.28

ServerTokens OS Apache/2.0.28 (Unix)

ServerTokens Full Apache/2.0.28 (Unix) SSL/2.0. 0

ServerSignature On/Off

ServerAdmin admin@email.example.com

Aliasing and Mapping of Resources

Alias /icons/ /usr/local/apache2/icons/

AliasMatch ^/help(.*) /usr/local/apache/htdocs/manual$1

URL Redirection

Redirect temp /news/ http://example.com/latest/news/

MIME Magic

mod_mime_magic

MimeMagicFile

The ForceType Directive

<Location /images/>ForceType image/gif</Location>

Directory Listings

DirectoryIndex index.html index.htm

mod_autoindex

Default Document Index

Directory Indexing

Forbidding Directory Access

● Disable the mod_autoindex● Use the Options-Indexes directive● Use IndexIgnore directive.

Icons for Bookmarks

AliasMatch /favicon.ico /usr/local/apache2/icons/site.ico

Icon

Reference

● Daniel Lopez Ridruezo; SAMS Teach Yourself Apache2 in 24 Hours, SAMS Publishing, 2002 (Buy this book on Amazon)

Recommended