Editing the Apache Web Server’s Configuration

Wading through Apache’s long configuration file isn’t as hard as it seems when you know what to look for.

The standard Apache configuration file, located at /etc/httpd/httpd.conf , is as large as it is well-documented. Take its introductory warning to heart:

Do not simply read the instructions . . . without understanding what they do. They’re here only as hints or reminders. If you are unsure, consult the online docs. You have been warned.

For your own reference, the online docs are available at the Apache web site (http://httpd.apache.org/docs/).

Unlike the user configuration (later in this hack), this is the heart of Apache; everything in this file controls what features (modules) Apache loads at startup, as well as the default set of access restrictions, file types, and so much more. When searching through this file for something specific (say, how do I turn on CGI [Hack #92]), the quickest way to find and learn is to search for the feature you want to enable. In our case, we’ll start looking for CGI. The first two matches we find are:

LoadModule cgi_module libexec/httpd/mod_cgi.so
AddModule mod_cgi.c

You’ll see a number of these lines within the Apache config file. If you’ve ever worked with a plug-in-based program, you’ll easily recognize their intent; these lines load different features into the Apache web server. Apache calls these modules, and you’ll see a lot of module names start with mod_, such as mod_perl and mod_php. Lines ...

Get Mac OS X Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.