22.3. Apache Modules

By means of modules, Apache can be expanded with a wide range of functions. For example, Apache can execute CGI scripts in diverse programming languages by means of modules. Apart from Perl and PHP, additional scripting languages, such as Python or Ruby, are also available. There are modules for secure data transmission (secure sockets layer, SSL), user authentication, expanded logging, and other functions.

By means of custom modules, Apache can be adapted to all kinds of requirements and preferences. This requires a certain amount of know-how. For further information, refer to Section 22.13.4. “Additional Sources”.

Several “handlers” can be specified for processing queries (by means of directives in the configuration file). These handlers can be part of Apache or a module invoked for processing the query, so this procedure can be arranged in a very flexible way. It is also possible to use custom modules with Apache to influence the way in which requests are processed.

The modularization in Apache 2 has reached an advanced level, where everything except some minor tasks is handled by means of modules. In Apache 2, even HTTP is processed by way of modules. Accordingly, Apache 2 does not necessarily need to be a web server. It can also be used for completely different purposes with other modules. For example, there is a proof-of-concept mail server (POP3) based on Apache.

Apache supports a number of useful features, some of which are described below.

Virtual Hosts

Support for virtual hosts means that a single instance of Apache and a single machine can be used for several web sites. To users, the web server appears as several independent web servers. The virtual hosts can be configured on different IP addresses or on the basis of names. This saves the acquisition costs and administration workload for additional machines.

Flexible URL Rewriting

Apache offers a number of possibilities for manipulating and rewriting URLs. Check the Apache documentation for details.

Content Negotiation

Apache can deliver a page that is adapted to the capabilities of the client (browser). For example, simple versions without frames can be delivered for older browsers or browsers that only operate in text mode, such as Lynx. In this way, the JavaScript incompatibility of various browsers can be circumvented by delivering a special page version for every browser (provided you are prepared to adapt the JavaScript code for each individual browser).

Flexible Error Handling

React flexibly and provide a suitable response in the event of an error, such as nonexistent pages. The response can even be generated actively, for example, with CGI.