3.3 Configuration


Apache was designed to be modular, so you can run as lean, or as bloated, a webserver as you like. We discuss the basic configuration and some minor tweaks; all the directives are described at httpd.apache.org/docs/mod/directives.html, but during your Linux installation, the documents were placed in /var/www/html/manual/mod/directives.html . You can reach them via the link on the default web page (for the time being, anyway, because we will be moving these documents later): http://localhost/manual/mod/directives.html .

3.3.1 Modifying the Default Configuration

Apache's configuration file is /etc/httpd/conf/httpd.conf . We'll start with the default configuration file from Apache version 1.3.24. [6] There are many comments in httpd.conf ; read them! This is a great way to get a feel for how the Apache configuration file works. Most of it you'll leave unchanged, but the comments will familiarize you with the available capabilities.

[6] Configuration files evolve over time, so don't worry too much if this stuff isn't exactly the same ” it probably won't be. By the way, as of this writing, 1.3.24 was the latest Red Hat version, but 1.3.27 had already been released, and version 2.0 was in beta.

First, change the following:

 ServerAdmin root@webserver.example.com 

to:

 ServerAdmin webmaster@example.com 

or whoever you want to get all the comments (and complaints) about your web site. You may want joe_user@example.com to be your e-mail address or, more preferably, a webmaster e-mail alias. It should be someone who checks e-mail frequently, for some value of frequent proportional to how often people look at your web site.

Apache logs every hit to the webserver (see the section on log files later in this chapter). Some of the information that can be written to the log includes the following:

  • The client (Web surfer) IP address

  • The date

  • The URI requested (all the stuff after www.example.com/ )

  • The referer [7] ”the web page the client was at when they clicked the link to take them to our web page

    [7] Yes, it's misspelled ”it was misspelled in the original spec, and we continue to do so in honor of our forefathers. Or maybe because it's just too much work to change all the old documents.

  • The user agent (the browser the client is using)

There are various predefined CustomLog options, logging more or less information. The default logged in /var/log/httpd/ includes some of this information (the client IP address, the date, and a few others). Until your site is running smoothly (and maybe even after), you'll want more information, so use the format that includes the most information. Change the following:

 CustomLog /var/log/httpd/logs/access_log common 

to:

 CustomLog /var/log/httpd/logs/access_log combined 

Other options include

 CustomLog /var/log/httpd/logs/access_log agent  CustomLog /var/log/httpd/logs/access_log referer 

But the combined format includes this information, as you might expect from the name . Using combinations of these options, you can customize your logging experience.



Open Source Development with Lamp
Open Source Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP
ISBN: 020177061X
EAN: 2147483647
Year: 2002
Pages: 136

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net