How to Administer Apache Web Servers
The Apache web server is extremely popular, running about 45 percent of the web servers on the Internet. Part of the popularity might be because of its straightforward method of configuration. The server is configured by changing flat configuration files. Configuration options, properly called "directives," are available for everything from the name of your server to the location of common error pages. It is not difficult to read through and change these options once you know where to look, but a basic understanding of what is going on and how to change settings is required.
Instructions
-
-
1
Explore the location of the Apache configuration files. On startup, the web server reads all of the files in the "conf" and "conf.d" directories and all their subdirectories, treating them essentially as one big configuration file. They are separated by convention only, for the sake of organization. The "conf" directory contains "httpd.conf," which normally contains server-wide directives. The "conf.d" directory contains one file for each site hosted on the server.
-
2
Learn the syntax for Apache configuration directives. The web server processes one directive per line and ignores lines beginning with "#." The default configuration file has many of these "comment" lines to explain the functionality of the various directives. If any line in the Apache configuration files is malformed, the server will not start.
-
-
3
Understand Apache's modular structure. The web server is comprised of the Apache "core" functionality and several add-on "modules." The default installation includes some basic modules, such as PHP and MySQL, but others can be added. The "LoadModule" directive is used to dynamically load a module. Configuration options for specific modules are placed within <IfModule modulename> and </IfModule>.
-
4
Understand configuration directive "scope." Apache has the capability to serve many websites simultaneously. Accordingly, some directives will apply only to certain sites, while others will apply to the entire server. You can enclose directives specific to the file name or directory name in <Files>...</Files> or <Directory>...</Directory>, respectively. To apply a directive to an entire site (but not the entire server), enclose it in <VirtualHost>...</VirtualHost>.
-
5
Understand user configuration access through .htaccess files. A user can set her own configuration settings by placing a file named ".htaccess" in any web server directory. These directives will only apply to the directory of the file and any subdirectories, and the server administrator can limit them with the AllowOverride directive in httpd.conf.
-
1
Tips & Warnings
After changing any configuration options, you must restart or reload the server to see the changes. You can test your configuration files without starting the server by running "apachectl configtest" from the command prompt.