When the Apache software has been installed in the directory you have selected, you are ready to begin configuration of the server. Earlier versions of the Apache server used multiple configuration files. However, now only the httpd.conf file is required. It is still quite handy to have multiple configuration files (for example, to make version upgrades easier). The include option will allow you to read additional configuration files from the main httpd.conf file.
Apache comes with a default configuration file that has the most common options set. If you are in a hurry to have your server running, this default configuration should cover the requirements to launch Apache. While functional, this configuration is not acceptable to many administrators. To begin fine-tuning the configuration, the first option most administrators choose is selecting the IP address and port information of the server.
Listen and BindAddress are the first two options that you may want to change.
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
#Listen 3000
Listen 172.16.0.4:80
This configuration change enables the Apache server to listen only on the specified interface and port. You can also use the BindAddress option to specify the IP address to which the server will bind. With this option, you are only specifying the IP address, not the port as above.
# BindAddress: You can support virtual hosts with this option. This directive
# is used to tell the server which IP address to listen to. It can either
# contain "*", an IP address, or a fully qualified Internet domain name.
# See also the <VirtualHost> and Listen directives.
#
BindAddress 172.16.0.4
When building Apache, you may have specified the installation directory. If so, the installation has automatically set the paths for your server root documents and all of your logfiles. If you need to change this, the following options will be useful:
ServerRoot
The location of the server's main configuration and logfiles
DocumentRoot
The location of your HTML documents, or other web content
By default, Apache will log to a path under its main server root path. If you have a different place on your system where you collect logs and would like to change the logfile paths, the following options will require changes:
CustomLog
The location of your access logfile
ErrorLog
The location of your error logfile
There are also some other useful options that can be set when configuring the logging settings on Apache:
HostnameLookups
Tells Apache whether it should look up names for logged IP addresses. It is a good idea to leave this setting turned off, since logging can be slowed if the server is attempting to resolve all names.
LogLevel
This option tells Apache how much information it should save to the logfiles. By default it is set at warn, but possible values are debug, info, notice, warn, error, crit, alert, and emerg. Each increasing level logs less information.
LogFormat
With this option, administrators can choose which format the logs are written in. Items such as date, time, and IP address can be rearranged to any format desired. The default settings are usually not changed.
By default, Apache is very friendly and will provide requesting users with a great deal of information about itself, including version information, virtual hostname, administrator name, and so on. Security conscious administrators may wish to disable this information, as it allows attackers a much quicker way of enumerating your server. While it is not a foolproof method of protecting your site, it can slow down would-be attackers who use automated scanning tools. The following two configuration options can help you limit the amount of information your server discloses:
ServerSignature
With this option turned on, the server adds a line to server-generated pages that includes all of its version information.
ServerTokens
Setting this option to Prod will prevent Apache from ever disclosing its version number.
Sites will always have different performance requirements. For many sites, the default settings provided with Apache will deliver all the required performance. However, busier sites will need to make some changes to the configuration to increase performance capabilities. The following options can be used in performance tuning a server. More information on Apache performance tuning can be found at the Apache Software Foundation's web site.
Timeout
The number of seconds before Apache will timeout receive and send requests.
KeepAlive
Enable this option if you want persistent connections enabled. It can be set to either on or off.
MaxKeepAliveRequests
Set this option to the number of keep-alive requests that you want the server to allow in persistent connections. Having a higher value here may increase performance.
KeepAliveTimeout
This is the number of seconds that Apache will wait for a new request from the current connected session.
These options are used to create a pool of spare servers that Apache can use when it is busy. Larger sites may wish to increase these numbers from their defaults. However, for each spare server, more memory is required on the server.
StartServers
This option tells Apache how many servers to start when first launched.
MaxClients
This is the option an administrator can use to limit the number of client sessions to a server. The Apache documentation warns about setting this option too low because it can adversely affect availability.
If you are feeling confident that your server is configured, and you're ready to run it, you will need to use apachectl, a tool provided with Apache that allows for the safe startup and shutdown of the server. The available options of apachectl are as follows:
start
Starts the standard HTTP server
startssl
Starts the SSL servers in addition to the regular server
stop
Shuts down the Apache server
restart
Sends a HUP signal to the running server
fullstatus
Prints out a full status of the web server, but requires mod_status
status
Displays a shorter version of the above status screen. Requires mod_status
graceful
Sends a SIGUSR1 to the Apache server
configtest
Inspects the configuration file for errors
While it's not mandatory to start Apache with apachectl, it is the recommended and easiest way to do so. apachectl makes shutting down the server processes quicker and more efficient, as well.