The Apache web server is the crown jewel of the Open Source software movement. It costs nothing to obtain, performs better than the competition, and is, so far, more widely used than all other Web servers combined. At the time of this writing 61.5% of all Web sites worldwide are using the Apache server.
Apache is free software. If you bought (as opposed to downloaded) the version of Linux you are running, Apache is probably on the distribution disks somewhere. Lacking that, you can download the latest version and many of the add-ons at
http://www.apache.org
Apache may very well already be installed on your system, but don't grope around looking for a file named "apache" it isn't there. For historical reasons the apache executable is a file called httpd. |
Organization
Apache is not a single file, but rather a collection of them. In addition to the httpd executable there is at least one configuration file (httpd.conf). Zero or more precompiled object files called modules may be dyanmically loaded in to the base httpd executable to provide additional functionality. Somewhere on the system, there should be a collection of Web page documents to be delivered by the server. For organizational reasons, all of these types of files are usually stored under a single directory, which is referred to as the ServerRoot. In fact, Apache requires a valid ServerRoot directory in order to function properly. Though the exact names and locations are configurable, you will typically find the following subdirectories under ServerRoot:
conf | configuration files |
logs | apache logs |
htdocs | static web page files |
cgi-bin | cgi scripts and binaries |
Directives
The behavior of Apache is largely controlled by the values of variables stored in the httpd.conf file. These variables are called directives. Directives, which limit the scope of other directives, are called container directives. For example, the VirtualHost directive can be used to surround other directives and thereby limit their scope to a single Web site on your server.
Ninety percent of the administration of apache is knowing what the directives are and how to set them.
The apachectl script
Apache's configuration files are read only at startup time. If you make a change to an apache directive, you must restart the server in order for the changes to take effect. The recommended method for restarting the server is to use the apachectl script:
apachectl restart
Before attempting to restart the httpd daemon, it's a good idea to check that your new configuration is valid. This can also be done with the apachectl script:
apachectl configtest
Virtual Host ing
Virtual Hosting is the practice of configuring your server so that it responds to requests for more than one Web site. There are two ways of configuring virtual hosting: by IP address and by name. The steps for configuring virtual hosting by name are discussed at the end of this chapter.