Modules in Apache

Apache Web server

Developed in 1995, the Apache web server is a powerful open-source application. It's users include The British Royal Family, the Financial Times and TechRepublic. It runs on almost every computer and OS and has many features and capabilities. No wonder it's the number one server on the Internet since 1996.

Modules

The Apache server is build out of several modules, which are pieces of computer code. By combining these pieces, you can create your own server and configure it for every detail. Many modules are installed by default, such as the mod_dir module, which serves a nice starting page instead of the directory contents.

Not only you can use the modules delivered with Apache, you can also use modules from third parties, which lets you integrate every application you can imagine with your server. You can compile modules in Apache, or install them using a tool like RPM.

This writing will cover six modules.

Dynamic content

Many modules enable dynamic content. Dynamic content means the pages are created just before they are sent to the one who asked for them. This enables you to include files in the dynamic pages, which makes updating easy, but you can also add some things to your page which change all the time, like the date or form-input. Using forms and cookies, you can customize all pages for every user.

Dynamic content is also used to access databases. A database stored in HTML isn't very easy to update, because things can be on more than one place. If you have a SQL database with all information, you only have to change the database to change every dynamic page you have.

Dynamic content can do a lot more, like web-applications or search-engines, so it's used by a lot of web sites.

CGI

CGI (Common Gateway Interface) is one way to include some dynamic content in your page. When a CGI script is read, it's executed by a program on the server. You could write a Perl script for example, or a shell script. When the script is executed, the output is shown on the screen. If you do want to include some HTML, you should write your script so it outputs the correct HTML. You can use CGI as all kind of files: you can create a HTML file, an image or an executable dynamically with CGI.

The script in which you write CGI (mostly Perl) is usually not made or suitable for the task it is supposed to do. Furthermore, the server has to load the CGI script and a powerful scripting language every time a CGI is requested, what makes it resource-intensive. CGI scripts are for these reasons mostly used to interpret form information and not to create dynamic pages.

When you provide users access to your web server to let them upload their pages, you probably don't want them to have access to your total computer. This is however possible with CGI, so you might be taking a great risk by letting your users write their own CGI scripts.

PHP

PHP (Personal Home Pages) is much used for dynamic pages and is made for the job. Started as a Perl hack, PHP has become more and more a real scripting language on it's own. This scripting language can be combined with HTML, so you can include a small part PHP in a HTML page instead of writing the whole page in PHP. It also has database capabilities and supports almost every database there is. PHP is much like Perl, but if you haven't programmed ever before, you'll find it a bit hard to learn.

Besides using databases as dynamic content, PHP can also deal very well with forms and cookies, which makes it very good for every customization or adaptation that a good site needs.

SSI

The Server Side Includes which is, like CGI, available with Apache, is not very powerful but implements just enough to make updating easy for small sites. Everybody with more than ten pages can make use of it. With SSI, you can include pages into other pages, which is useful if you have something like a menu on every page. Do you want to change something to the menu (e.g. add an extra item) you only have to change the file where the menu is in and the web server will "paste" the menu in all other files, on the places you defined.

SSI also supports some dynamics such as different pages for every browser, but not as powerful as PHP.

Securing your site with SSL

Of course not all modules are about dynamic content, much of them are about securing your web server. Normally, all the Internet traffic is unencrypted and can be read easily with a sniffer. You can use SSL to encrypt your pages and other content, so that credit card-numbers or other privacy-sensitive content can't be read that easily.

It doesn't mean that you are save when you encrypt everything. If someone can reach the data otherwise, like by a telnet session to the server or by searching in the cache of a client's browser, it doesn't matter whether you encrypt your pages or not.

Authorizing

In some cases, it's important that not everybody can read all information on a web server. If you want to make particular information only available for some users, like members, authorized users or users who payed you, you could use a password on a part of your server. This can be done by using the authorizing module, which asks for a username and password. This is far more save than JavaScript or other scripting language and the password is encrypted. There are also modules that get the password from other places, like a database or the system's password file.

User tracking

Sometimes you would like to know what pages are visited often and which not. With the usertracking module, you can see not only how many people are visiting your site, but also where they come from and which links they clicked, etcetera. This is often useful information: you can spend more time or place advertisements on the pages that are much visited, or place links to the right pages.

Conclusion

Apache is very easy to configure and there are modules for almost everything. Most modules are very easy to use and configure and you should not have to spend hours on using an extra module.

More information

For more information you could visit the PHP or Apache sites. On the Apache web site there are links and texts about all modules named in this text.