Apache Web Server

July 19, 2007 / Dedicated Server Hosting Web Hosting

What is Apache Web Server?

The Apache HTTP Server referred to simply as Apache, is a web server notable for playing the main role in the initial growth of the World Wide Web. Apache was the first viable alternative to the Netscape Communications Corporation web server (currently known as Sun Java System Web Server) and has since evolved to rival other Unix-based web servers in terms of functionality and performance.

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient, and extensible server that provides HTTP services in sync with the current HTTP standards. Netcraft Web Server Survey found that more than 70% of the websites on the Internet are using Apache, thus making it more widely used than all other web servers combined.

Development of the Apache Web server perform by a group of about 20 volunteer programmers, called Apache Group. However, because the source code is freely available, anyone can adapt the server for specific needs, and there is a large public library of Apache add-ons. In many respects, the development of Apache is similar to the development of the Linux operating system. The original version of Apache was written for UNIX, but their version run under OS/2, Windows, and other platforms.

How to Setup Apache as a Web Server?

For setup follow these steps:-

The Web server made for keeping Websites. Three ways a Website stored. They are:
a) default directory hosting
b) virtual directory hosting
c) virtual domain hosting

First We have to configure the DNS. Then configure the following file (redhat 6.2) /etc/httpd/conf/httpd.conf If we use Apache as a Web server whether, on Windows platform or Linux, the main file which used called /etc/httpd/conf/httpd.conf

The root directory of Web server /etc/httpd, which 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 the Web server)

Let’s open the file /etc/httpd/conf/httpd.conf and take a detailed look at the macros to use.

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 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
and then
/usr/conf/access.conf
unless you have overridden these with ResourceConfig and/or AccessConfig directives here.

Directives

The config directives 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 response 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.

First Section: 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 config files.

ServerType: ServerType is either inetd, or standalone. Inetd mode only supported on Unix platforms.

ServerRoot: The top of the directory tree under which the server’s configuration, error, and log files are kept.

NOTE: Do not add a slash at the end of the directory path.4
ServerRoot “/etc/httpd”

LockFile: The LockFile directive sets the path to the lockfile used when Apache is compiled with either
USE_FCNTL_SERIALIZED_ACCEPT or
USE_FLOCK_SERIALIZED_ACCEPT.

This directive should normally be left at its default value. The main reason for changing it is if the logs directory is NFS mounted since the lock file must be stored on a local disk. The PID of the main server process is automatically appended to the filename.
LockFile /var/lock/httpd.lock

PidFile: The file in which the server should record its process identification number when it starts.
PidFile /var/run/httpd.pid

ScoreBoardFile: File used to store internal server process information. Not all architectures require this. But if yours does (you’ll know because this file will created when you run Apache) then you must ensure that no two invocations of Apache share the same scoreboard file.
ScoreBoardFile /var/run/httpd.scoreboard

In the standard configuration, the server will process this file, srm.conf, and access.conf in that order. The latter two files now distributed empty, as it recommends that all directives keep in a single file for simplicity. The commented-out values below are the built-in defaults. You can have the server ignore these files altogether by using “/dev/null” (for Unix) or “nul” (for Win32) for the arguments to the directives.

ResourceConfig conf/srm.conf
AccessConfig conf/access.conf

Timeout: The number of seconds before receiving and sending time out.
Timeout 300

KeepAlive: Whether or not to allow persistent connections (more than one request per connection). Set to “Off” to deactivate. But we keep it :
KeepAlive On

MaxKeepAliveRequests: The maximum number of requests to allowed during a persistent connection. Set to 0 to allow an unlimited amount. We recommend you leave this number high, for maximum performance.
MaxKeepAliveRequests 100

KeepAliveTimeout: Number of seconds to wait for the next request from the same client on the same connection.
KeepAliveTimeout 15

Server-pool size regulation: Rather than making you guess how many server processes you need, Apache dynamically adapts to the load it sees — that is, it tries to maintain enough server processes to handle the current load, plus a few spare servers to handle transient load spikes (e.g, multiple simultaneous requests from a single Netscape browser).

It does this by periodically checking how many servers are waiting for a request. If there are fewer than MinSpareServers, it creates a new spare. If there are more than MaxSpareServers, some of the spares die off. The default values are probably OK for most sites.
MinSpareServers 5
MaxSpareServers 20

The number of servers to start initially should be a reasonable ballpark figure.
StartServers 8

Limit the total number of servers running: Limit the number of clients who can simultaneously connect. If this limit ever reached, the client `locked out’, so it should not set too low. It intended, mainly, as a brake to keep a runaway server from taking the system with it as it spirals down.
MaxClients 150

MaxRequestsPerChild: The number of requests each child process 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 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.

NOTE: This value does not include keepalive requests after the initial request per connection. For example, if a child process handles an initial request and 10 subsequent “keptalive” requests, it would only count as 1 request towards this limit.
MaxRequestsPerChild 100

Listen: This allows you to bind Apache to specific IP addresses and/or ports, in addition to the default. See also the directive.
Listen 3000
Listen 12.34.56.78:80

BindAddress: You can support virtual hosts with this option. This directive 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.
BindAddress *