Вы находитесь на странице: 1из 14

School of

Computer Science and


Information Technology

COSC1300 / COSC1301
Web Servers and
Web Technology
Configuring Apache for Production
Week 5

Container Directives

Web Servers and


Web Technology

Container directives are used to limit scope of the

Apache directives. There are nine container directives


available:

Limit
LimitExcept
Directory
DirectoryMatch
Files
FilesMatch
Location
LocationMatch
VirtualHost
The most useful, and often used, are the Directory and VirtualHost
containers.

Semester 1, 2012

RMIT Department of Computer Science and IT

Container Directives

Web Servers and


Web Technology

Within a container directive other directives can be set. These

directives will only be in effect for the scope of the container.


A Directory container specifies a single directory (and all
subdirectives) as the scope. For example:
<Directory "/iweb/s3201234/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

</Directory>

Here the Options, AllowOverride and Order allow,deny (see

the Tutorial Configuring Apache for access control)


directives apply to the web document root and all directories
beneath it.

Semester 1, 2012

RMIT Department of Computer Science and IT

Options

Web Servers and


Web Technology

The Options directive controls features of the server.


There are seven specific parameters, plus All, which
is default:

ExecCGI - allows execution of CGIs.


FollowSymLinks - allows server symbolic links to be
followed.
Includes - enables Server-Side Includes (SSI).
IncludesNOEXEC - same as above but with exec disabled.
Indexes - allows directory listings to be generated.
MultiViews - allows content negotiated MultiViews.
SymLinksIfOwnerMatch - allows symbolic links to be
followed only if target file and the link have the same user
id.
Semester 1, 2012

RMIT Department of Computer Science and IT

Default Page and Options


Indexes

Web Servers and


Web Technology

One of the Options directive parameters is Indexes.

This is related to default pages.


Of course, the default page must exist in the
directory to be served.
If it doesnt there are two possibilities, depending on
the setting of the Options directive.
If Indexes is set, a dynamically generated list of the files
in the directory is presented to the user.
If Indexes is not set, an error page is presented (which
error code is appropriate here?).

Semester 1, 2012

RMIT Department of Computer Science and IT

Access Log

Web Servers and


Web Technology

By default, the Apache logs are stored in the apache2/logs/

directory. There is a log that stores all incoming requests,


and a log that stores all errors. The access log records
information about every request made to the web server.
The access log directives are:

LogFormat - This directive specifies a logging format which fields to


record in the log. There can be multiple entries for this directive.
CustomLog - This directive specifies where to write the access log,
and which format to write it in.

What is the default access log file of your apache web server?
What is the default log format being used?

Semester 1, 2012

RMIT Department of Computer Science and IT

Error Log

Web Servers and


Web Technology

The error log is useful during configuration. If you

have any problems with configuration, the error log


should be examined to provide more information
about the problem.
The error log directives are:
ErrorLog - the name and location of the log file.
LogLevel - the amount of information to be logged.

What is the default error log file of your apache web


server? What is the default level of error log?

Semester 1, 2012

RMIT Department of Computer Science and IT

Per-user Web Directories

Web Servers and


Web Technology

Apache web server allows you to create user-specific


directories to be accessed using the
name:<port>/~user/.
For example

http://server-host-

http://yallara.cs.rmit.edu.au/~ronvs.

UserDir directive sets the directory in a user's home


directory to use when a request for a document for
a user is received.
What is the default value of the UserDir directive?
What does it mean?
(read: http://httpd.apache.org/docs/2.0/mod/mod_userdir.html#userdir)

Semester 1, 2012

RMIT Department of Computer Science and IT

Customizing the Error Pages

Web Servers and


Web Technology

Apache will return an error page in case of errors

such as Forbidden, Not Found, Unauthorized,


etc. Apache has its default page for each of the
possible errors.
Using ErrorDocument directive, in the event of a
problem or error, Apache can be configured to do
one of four things:
output a customized message
redirect to a local URL-path to handle the problem/error
redirect to an external URL to handle the problem/error

How do you customize the error page for the event


when the file being requested does not exist?

Semester 1, 2012

RMIT Department of Computer Science and IT

Per-Directory Configuration

Web Servers and


Web Technology

The per-directory configuration directives are:


AccessFileName
the

name of the per-directory configuration file, by default


.htaccess.

AllowOverride
the

level of directives that can be overridden in the per-directory


configuration file.

These apply to the current directory and all


subdirectories.

Semester 1, 2012

RMIT Department of Computer Science and IT

10

AllowOverride

Web Servers and


Web Technology

There are five specific parameters, plus All and


None:

FileInfo allows use of directives controlling document


types, ErrorDocument, SetHandler
Indexes allows use of directives controlling indexing,
DirectoryIndex, FancyIndexing
AuthConfig allows authorisation directives (more later)
Options Lots of things! (more later)
Limit allows use of directives controlling access, Order
Allow,Deny (more later)

When should you use per-directory configuration?


When should you not use per-directory
configuration?

Semester 1, 2012

RMIT Department of Computer Science and IT

11

Virtual Hosts

Web Servers and


Web Technology

The VirtualHost container allows the Apache web server to

host more than one site. Each site is distinguished with a


separate domain name.
Virtual hosting can be done based either on IP addresses (IP
based) or domain names (named based). Because IP
addresses are scarce, named based virtual hosting is
preferred.
Only HTTP/1.1 supports named based virtual hosting. This is
done with the mandatory use of the Host header. This header
specifies which domain name to connect to for a web server
at a particular IP address. Using a HTTP/1.0 browser does
not allow named based virtual hosting to work.
Read: http://httpd.apache.org/docs/2.0/vhosts/name-based.html

Semester 1, 2012

RMIT Department of Computer Science and IT

12

Adding a DSO Module

Web Servers and


Web Technology

If apache is installed using --enable-so option, dynamic

modules can be installed on top of the current apache


installation.
The following are the steps to install a dynamic module:
1.Go to where the module is located. Apache built-in modules
are located under modules directory of the apache source
directory.
cd /iweb/username/src/httpd-2.0.58/modules/blah

2.Compile the module using apxs tool.


/iweb/username/apache2/bin/apxs c mod_foo.c

3.Install the module using apxs tool.


/iweb/username/apache2/bin/apxs i a n foo mod_foo.la

Semester 1, 2012

RMIT Department of Computer Science and IT

13

References

Web Servers and


Web Technology

http://httpd.apache.org/docs-2.0/- documentation for Apache


2.0.

Reading 3 - Configuring Apache the Way You Want It.

Semester 1, 2012

RMIT Department of Computer Science and IT

14

Вам также может понравиться