Configuring Apache – Intermediate - Modules
(Page 2 of 4 )
One of the most useful features of Apache is its modular nature. Apache was and is developed with the intention of having other code blocks plugged into it to add new capabilities to the server. Some well-known examples of this modular nature are the PHP and Perl pre-processors. Each of those server-side languages require that the Web server knows how to handle certain files before they get sent out to a client. Apache allows the administrator to configure “handlers” for certain types of files that map a certain file extension to a specific module to have it run through that module’s code before it gets returned to the client. Modules can also do many more things than just filter text, but each module needs to be addressed on it’s own.
Probably the most popular module to add to Apache is PHP, since PHP is one of the most popular and best known Web programming languages. Adding it to Apache 2.0 is really relatively easy. To do this, you must begin by downloading and installing the PHP files. Once you have done this, adding support to Apache for PHP is simple. All you need to do is add a few lines to the httpd.conf file. These lines are as follows. First, you must tell Apache to load the PHP module:
LoadModule php4_module libexec/libphp4.so
The above line tells the Apache server to load the module “libexec/libphp4.so” as the module named “php4_module.” Next, we must associate a certain file extension with the PHP interpreter, so that PHP files get parsed and processed correctly. We do this with the following AddType line:
AddType application/x-httpd-php .php
This line associates the “.php” file extension with the PHP interpreter, which tells the server to parse files ending in “.php” through the PHP interpreter.
All of the above configuration is simple, really, on the Apache side for setting up PHP. Remember, however, that you must separately configure the PHP engine itself in a different file, called “php.ini.”
Next: Authentication >>
More Web Hosting How-Tos Articles
More By Michael Swanson