Apache has been the most popular web server on the internet since April
1996. The January 2002 Netcraft Web Server Survey found that 56% of the
web sites on the Internet are using Apache, thus making it more widely
used than all other web servers combined.
Apache
Web Server was developed under the Apache HTTP Server Project. It is an
open-source HTTP server for various modern desktop and server operating
systems, such as UNIX and Windows NT. The goal of this project is to provide
a secure, efficient and extensible server, which provides HTTP services
in sync with the current HTTP standards.
Configuration
We have to first configure the DNS. Then configure the following file
/etc/httpd/conf/httpd.conf.
The root directory of Web server is /etc/httpd, which is divided into
three parts:
1) /etc/httpd/conf (where configuration files stays)
2) /etc/httpd/logs (where the logs of Web server and site accessing stay)
3) /etc/httpd/modules (where the module stays, which enables the server
side programmer to do programming in the languages supported by Web server)
Now lets take a look at the file /etc/httpd/conf/httpd.conf.
httpd.conf-Apache HTTP server configuration file
This is the main Apache server configuration file. It contains the configuration
directives that give the server its instructions.
After this (httpd.conf) file is processed, the server will look for and
process (only in the case of 6.1 the following mentioned file is checked.
If it is 6.2 they are not checked):
/usr/conf/srm.conf
/usr/conf/access.conf
unless you have overridden these with ResourceConfig and/or AccessConfig
directives here.
Directives
The configuration directives are grouped into three basic sections:
1) Directives that control the operation of the Apache server process
as a whole (the 'global environment').
2) Directives that define the parameters of the 'main' or 'default' server,
which responds to requests that aren't handled by a virtual host. These
directives also provide default values for the settings of all virtual
hosts.
3) Settings for virtual hosts, which allow Web requests to be sent to
different IP addresses or hostnames and have them handled by the same
Apache server process.
Global
Environment
The directives in this section affect the overall operation of Apache,
such as the number of concurrent requests it can handle or where it can
find its configuration files.
ServerType: ServerType is either inetd, or standalone. Inetd mode
is only supported on Unix platforms.
ServerRoot: The top of the directory tree under which the server's
configuration, error, and log files are kept.
PidFile: The file in which the server should record its process
identification number when it starts.
ScoreBoardFile: File used to store internal server process information.
Not all architectures require this. In the standard configuration, the
server will process this httpd.conf, srm.conf, and access.conf in that
order. The latter two files are now distributed empty, as it is recommended
that all directives be kept in a single file for simplicity.
Timeout: The number of seconds before it receives and sends a
time out.
KeepAlive: Whether or not to allow persistent connections (more
than one request per connection). Set to "Off" to deactivate.
MaxKeepAliveRequests: The maximum number of requests to be allowed during
a persistent connection. Set to 0 to allow an unlimited amount. We recommend
you leave this number high, for maximum performance.
KeepAliveTimeout: Number of seconds to wait for the next request from
the same client on the same connection.
MaxRequestsPerChild: The number of requests each child process
is allowed to process before the child dies. The child will exit so as
to avoid problems after prolonged use when Apache (and maybe the libraries
it uses) leak memory or other resources. On most systems, this isn't really
needed, but a few (such as Solaris) do have notable leaks in the libraries.
For these platforms, set to something like 10000 or so; a setting of 0
means unlimited.
ThreadsPerChild: Number of concurrent threads (i.e., requests)
the server will allow. Set this value according to the responsiveness
of the server (more requests active at once means they're all handled
more slowly) and the amount of system resources you'll allow the server
to consume.
Listen: Allows you to bind Apache to specific IP addresses and/or
ports, in addition to the default.
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.
'Main' server configuration:The directives in this section set
up the values used by the 'main' server, which responds to any requests
that aren't handled by a definition. These values also provide defaults
for any containers you may define later in the file.
Port: The port to which the standalone server listens.
ServerAdmin: Your address, where problems with the server should
be emailed. This address appears on some server-generated pages, such
as error documents.
ServerName: Allows you to set a host name which is sent back to
your server if it's different than the one the program would get (i.e.,
use "www" instead of the host's real name).
DocumentRoot: The directory out of which you will serve your documents.
By default, all requests are taken from this directory, but symbolic links
and aliases may be used to point to other locations.
UserDir: The name of the directory that is appended onto a user's
home directory if a user request is received.
DirectoryIndex: Name of the file or files to use as a pre-written
HTML directory index. Separate multiple entries with spaces.
AccessFileName: The name of the file to look for in each directory
for access control information.
CacheNegotiatedDocs: By default, Apache sends "Pragma: no-cache"
with each document that was negotiated on the basis of content. This asks
proxy servers not to cache the document. Uncommenting the following line
disables this behavior, and proxies will be allowed to cache the documents.
UseCanonicalName: (new for 1.3) With this setting turned on, whenever
Apache needs to construct a self-referencing URL (a URL that refers back
to the server the response is coming from) it will use ServerName and
Port to form a "canonical" name. With this setting off, Apache
will use the hostname: port that the client supplied, when possible. This
also affects SERVER_NAME and SERVER_PORT in CGI scripts.
TypesConfig: Describes where the mime.types file (or equivalent)
is to be found.
HostnameLookups: Log the names of clients or just their IP addresses.
The default is off.
ErrorLog: The location of the error log file.
LogLevel: Control the number of messages logged to the error_log.Possible
values include: debug, info, notice, warn, error, crit, alert, emerg.
Aliases: Add here as many aliases as you need (with no limit).
Redirect: Allows you to tell clients about documents which used
to exist in your server's namespace, but do not anymore. This allows you
to tell the clients where to look for the relocated document.
Virtual Hosts
If you want to maintain multiple domains/hostnames on your
machine you can setup Virtual Host containers for them. Most configurations
use only name-based virtual hosts so the server doesn't need to worry
about IP addresses. Please see the documentation at http://www.apache.org/docs/vhosts/
for further details before you try to setup virtual hosts.