Jump Start your Intranet Web Sites - Setting up Virtual Hosts on Apache
Linux #6 Stairway to Heaven? - Setting up your Linux Server as an Internet Gateway!
Linux #5 What's in a name? - Domain Name Server on Linux
You are here: irt.org | Articles | Linux & Apache | Made to Measure : Apache Web Server Customization [ previous next ]
Published on: Sunday 22nd August 1999 By: Pankaj Kamthan
Apache Web server originated from a series of "patches" to the NCSA Web server. As benchmark comparisons provided by Netcraft surveys show, its use has grown steadily over the last five years and it is the most popular Web server in use today. A comparison of features of a large number of Web servers currently in use is available at WebServer Compare. A quick overview of features of Apache is available here.
One of the key features of Apache is its "modular" architecture which makes is possible for anyone to add new functions to the server. In fact, most of the code that comes as part of the Apache distribution is in the form of modules, and can be removed or replaced. It has a generalized interface to modules that extends the functionality of the base package.
There are a large number of modules now written for Apache. Besides those included with the distribution, modules are also written to add functions not already in the code, or to do things which are needed on some sites but are not of widespread use. Some of these modules are written by Apache developers. Most of them, however, are written by other users of Apache who want to adapt its functionality for their needs.
In this article, we will look at a range of Apache modules which can be configured in the Apache server, and the range of advantages they offer. We will restrict ourselves specifically to UNIX-type and occassionally to Windows 9x/NT systems, though the basic ideas carry over to other systems.
There are various modules that come with the Apache distribution. All the standard Apache modules currently shipped (provided you downloaded the source and not the binary) reside in Apache's src directory. However, only selected modules are compiled in by default. For example, mod_cgi (for invoking CGI scripts) is and mod_example (for demonstrating Apache API) is not compiled in by default. A list of standard modules, the ones that are compiled-in by default and the ones that are not compiled-in, is given in Appendix I.
There are two reasons due to which you might like to customize your server:
It is quite simple to enable or disable a standard module. All you need to do is suitably edit the Configuration file in the src directory. On UNIX-type systems, module selection lines begin with AddModule and have the format:
AddModule modules/standard/mod_name.o
or
# AddModule modules/standard/mod_name.o
Uncommenting/commenting will enable/disable a module on compilation.
Note the following:
Suppose you have installed a Apache binary for Windows 9x/NT systems. It comes with a selected few standard modules in form of DLLs which are kept in the modules directory. You can obtain other module DLLs (such as for mod_perl) which you can enable by placing them in modules directory, and restarting Apache. The Windows version of Apache is configured to be able to load dynamic objects by default.
Modules reflect the features supported by Apache. Therefore, knowing the list of modules available is useful in order to take advantage of those features.
As an example, Apache supports Common Gateway Interface (CGI) scripts through the module mod_cgi, Server-Side Includes (SSI) and eXtended Server-Side Includes (XSSI) through the module mod_include, (server-side) image maps through the module mod_imap, content negotiation through the module mod_negotiation, cookies through the module mod_usertrack, URL-to-URL and URL-to-filename mapping using mod_rewrite, and correcting minor spelling errors in URL through the module mod_speling. Appendix I lists modules that can be useful for other applications.
There are a variety of nonstandard or "third-party" modules developed by users around the world. They can be found in the Module Registry Database.
To add a module to Apache, you need to carry out the following steps:
First, you will need to download the module. Here is a CGI referral search gateway to the Apache Module Registry Database. You may separate keywords with the boolean conditionals AND and OR to control your search results. Search without parameters returns a complete listing of the database.
A selected list of nonstandard modules is given in Appendix II. Most modules come as a single of the form mod_*.c. Place this file in Apache's src/modules/extra directory. If the module comes as more than one file, (for example, the mod_php module) follow the instructions that come with the module.
Once you have obtained the module source, Apache needs to be configured so that it will compile this code. To do that, edit the Configuration file in the src directory, and add a suitable AddModule line:
AddModule modules/extra/mod_name.o
The last argument on the AddModule line is the filename of the module, with the .c replaced by .o.
After editing Configuration file, re-compile Apache by typing the following:
./Configure make
Finally, stop (if you are running) the server,for example, with:
kill -TERM pid
install the new HTTPD executable, and start it, for example, with:
./httpd -f /usr/local/bin/httpd
It is usually more convenient to have aliases for starting and stopping commands.
For Windows 9x/NT, after downloading a module DLL (such as for coldfusion_module), place it in the modules directory. Then edit the httpd.conf file to include the following directive:
LoadModule name_module modules/module_name.dll
and restart Apache.
The power that comes with the standard modules is further enhanced by the availability (mostly free) of nonstandard modules written for various purposes by users around the world.
Arguably, the ones that are most useful from a developer's viewpoint, are embedded language interpreter modules, for example, mod_perl, which embeds the Perl language interpreter, or mod_pyapache, which embeds the Python language interpreter. They open up an entire host of new applications which have previously been nonexistent. Often scripting languages such as Perl and Python are used to write CGI scripts but tend to suffer from performance problems. With the use of corresponding modules mentioned above, one can have significant performance gain when using CGI scripts written in these languages and running them under Apache. These CGI scripts can now also access Apache internals. Besides that, one can even write Apache modules (which have traditionally written in C) in these languages. With the module mod_javascript, one can now take advantage of server-side JavaScript, which till now has only been available in Netscape FastTrack and Enterprise servers.
Apart from embedded interpreter modules, there are various other useful modules: apache_ssl, which provides Secure Socket Layer (SSL) protocol extension in Apache and makes it run as a secure server; mod_fastcgi for FastCGI, which speeds up CGI script via co-processing; and mod_auth_msql and mod_auth_mysql for authentication against mSQL and mySQL databases, respectively. Appendix II lists modules that can be useful for other applications.
One of major powers of Apache come from the pool of modules it offers. This power can be unleashed by knowing what this pool consists of, how it can be configured, and how it can be extended.
This appendix (alphabetically) lists of all of the standard modules that are part of the current (version 1.3.x) Apache distribution. Table 1 the modules that are compiled-in by default and Table 2 lists the ones which are not.
MODULE | FUNCTION |
---|---|
mod_access | Host based access control |
mod_actions | Filetype/method-based script execution |
mod_alias | Aliases and redirects |
mod_asis | The .asis file handler |
mod_auth | User authentication using text files |
mod_autoindex | Automatic directory listings |
mod_cgi | Invoking CGI scripts |
mod_dir | Basic directory handling |
mod_env | Passing of environments to CGI scripts |
mod_imap | The imagemap file handler |
mod_include | Server-parsed documents |
mod_isapi | Windows ISAPI extension support |
mod_log_config | User-configurable logging |
mod_mime | Determining document types using file extension |
mod_negotiation | Content negotiation |
mod_setenvif | Set environment variables based on client information |
mod_status | Server status display |
mod_userdir | User home directories |
mod_unique_id | Generate unique request identifier for every request |
mod_usertrack | User tracking using Cookies |
Table 1. Apache Standard Modules Compiled-In by Default.
MODULE | FUNCTION |
---|---|
mod_auth_anon | Anonymous user authentication, FTP-style |
mod_auth_db | User authentication using Berkeley DB files |
mod_auth_dbm | User authentication using DBM files |
mod_cern_meta | Support for HTTP header metafiles |
mod_digest | MD5 authentication |
mod_example | Demonstrates Apache API |
mod_expires | Apply Expires: headers to resources |
mod_headers | Add arbitrary HTTP headers to resources |
mod_info | Server configuration information |
mod_log_agent | Logging of user agents |
mod_log_referer | Logging of document references |
mod_mime_magic | Determining document types using "magic numbers" |
mod_mmap_static | Mapping files into memory for faster serving |
mod_proxy | Caching proxy abilities |
mod_rewrite | Powerful URI-to-filename mapping using regular expressions |
mod_so | Experimental support for loading modules (DLLs on Windows) at runtime (not compiled-in the UNIX distribution) |
mod_speling | Automatically correct minor typos in URLs |
Table 2. Apache Standard Modules Not Compiled-In by Default.
This appendix is a list of some nonstandard Apache modules. The selection is biased towards modules for programming language support and Web site administration. See Table 3.
MODULE | FUNCTION |
---|---|
apache_ssl | SSL extensions for Apache |
mod_bandwidth | Limit bandwidth based on number of connections |
mod_cint | Embedded C/C++ interpreter module for apache |
Chili!ASP | Active Server Pages module |
ColdFusion Module | Interface to the ColdFusion application server (Windows NT only) |
Cookie Authentication | Fake Basic authentication using Cookies |
dir_log_module | Implements per-directory logging |
Distributed Permanence Control Apache Module | Module designed to work with RCS and CVS to encourage the permanence of document version/editions on the Web |
FastCGI | Keeps CGI processes alive to avoid per-hit forks |
GIF Counter | Basic GIF counter |
Hotwired Mod_include | Hotwired extensions to mod_include |
Indexer | Configurable directory listing module |
Java Wrapper Module | Enables execution of Java applications as CGI directly |
mod_allowdev | Restricts access to filespace more efficiently |
mod_auth_ldap | Apache LDAP authentication module |
mod_auth_mysql | mySQL authentication module |
mod_auth_udp | External authentication using UDP |
mod_cgisock | Socket implementation of the CGI |
mod_format | Formats C, C++, and Java source code using HTML |
mod_gunzip | On-the-fly decompression of HTML documents |
mod_hosts_access | Allows you to use the hosts.allow and hosts.deny files to configure access to Apache |
mod_javascript | JavaScript module (ECMA-262) |
mod_jserv | Java servlet interface |
mod_neoinclude | NeoWebScript - Tcl scripting extension |
mod_perl | Embeds Perl language interpreter and provides a Perl interface to the server API |
mod_ssl | Free Apache interface to SSLeay |
mod_weborb | Directly invokes CORBA-objects to handle CGI requests |
mod_auth_msql | Basic authentication with the mSQL database |
parselog | Perl script to parse and store logs by server and date |
PHP | Server-side scripting language with extensive database support |
mod_pyapache | Embedded Python language interpreter |
TalentSoft WebPlus (Web+) | Web+ (WebPlus) application development tool/database middleware. Supports Linux, Apache API, mySQL, miniSQL, PostgreSQL, etc. |
WebCounter | Page counter |
Table 3. Apache Nonstandard Modules.
Jump Start your Intranet Web Sites - Setting up Virtual Hosts on Apache
Linux #6 Stairway to Heaven? - Setting up your Linux Server as an Internet Gateway!
Linux #5 What's in a name? - Domain Name Server on Linux
Linux #4 "Setting up DHCP is not P2C2E"