Apache Web Server

The Apache web server is the best, and most preferred, HTTP server software in use on the Internet today, and it was written entirely as a volunteer project, by volunteer programmers, in their spare time.

WWW

  • The Internet has been around for a long time. More than 30 years now.

  • In 1991, Tim Berners-Lee developed something that he called the World Wide Web, while working at CERN. His purpose was to give quick and easy access to documents for geographically distributed people collaborating on projects.

  • Along with a lot of help from the standard community (and, notably, Roy Fielding), they defined HTTP, HTML, URLs, and the other necessary components of making the Web a reality.

  • He then went off, and with the help of colleagues around the world, communicating via email, developed the CERN web server, and a simple Web client, which he dubbed a browser.

  • The name came about because there was very little of real value on the Web at that time, and all you ever really did was browse. Ironic that the name stuck!

NCSA

NCSA started working on the NCSA HTTPd (HyperText Transfer Protocol Daemon). Although that project is not active any more, you can still see the web site of the project at http://hoohoo.ncsa.uiuc.edu/ It still contains a wealth of information, most of which is still relevant, because the standards have not changed much in 8 years.

Rob McCool wrote the original code for the NCSA HTTPd, and this code was distributed without charge to the community, for them to use, with the understanding that if they fixed bugs, or added features, that they would then contribute them back to Rob to put into future versions.

The Apache Server

It describes the basic configuration of the http service, and covers advanced topics such as adding server modules, setting up virtual hosts, or configuring the secure HTTP server.

There are important differences between the Apache HTTP Server 2.2 and version 2.0, and if you are upgrading from a previous release of Red Hat Enterprise Linux, you will need to update the http service configuration accordingly.

Apache Server Versions

Since its initial launch the web server has undergone a number of improvements, which led to the release of several versions. All of the versions are accompanied by comprehensive documentation archives.

Apache 1.3

Apache 1.3 boasts a great deal of improvements over 1.2, the most noteworthy of them being - useful configurable files, Windows and Novell NetWare support, DSO support, APXS tool and others.

Apache 2.0

Apache 2.0 differs from the previous versions by the much re-written code, which has considerably simplified its configuration and boosted its efficiency. It supports Ipv6, Unix threading, other protocols such as mod_echo. This version also offers a new compilation system and multi-language error messaging.

Apache 2.2

Apache 2.2 came out in 2006 and offers new and more flexible modules for user authentication and proxy caching, support for files exceeding 2 GB, as well as SQL support.

New Features

The Apache HTTP Server version 2.2 introduces the following enhancements:

  • Improved caching modules, that is, mod_cache and mod_disk_cache.

  • Support for proxy load balancing, that is, the mod_proxy_balancer module.

  • Support for large files on 32-bit architectures, allowing the web server to handle files greater than 2GB.

  • A new structure for authentication and authorization support, replacing the authentication modules provided in previous versions.

Configuring apache

The configuration file used by Apache is /etc/httpd/conf/httpd.conf. Like most Linux applications you have to restart Apache before changes to the configuration file will take effect. Examples of how to configure this file will follow.

Configure the /etc/httpd/conf/httpd.conf file

The httpd.conf file is the main configuration file for the Apache web server. Edit the httpd.conf file,

#vi /etc/httpd/conf/httpd.conf
Go to Last Line of the file and type
<VirtualHost  *:80>
ServerAdmin  root@linux.wst.com
DocumentRoot  /var/www/html
ServerName  linux.wst.com
</VirtualHost>
:wq!
#service httpd restart

Where to put your web pages

All the statements that define the features of each web site are grouped together inside their own Virtual Host section or container in the httpd.conf file. The most commonly used statements or directives inside a Virtual Host container would be: server name which defines the name of the website managed by the Virtual Host container. This is only needed in Named Virtual Hosting. Document Root defines the directory in which the web pages for the site can be found. By default, Apache will search the Document Root directory for an index or home page named index.html.

In the example below we create a symbolic link to index.html in the /home/www/site1 directory.

[root@wilshire~]# cd /home/www/site1
[root@wilshire~]# ln -s index.htm index.html
[root@wilshire~]# ll index.*

-rw-rw-r– 1 root root 48590 Jun 18 23:43 index.htm lrwxrwxrwx 1 root root 9 Jun 21 18:05 index.html -> index.htm The “l” at the very beginning of the index.html entry signifies a link and the “->” the link target. The Default File Location By default, Apache expects to find all its web page files in the /var/www/html/ directory with a generic Document Root statement at the beginning of httpd.conf. The examples will use the /home/www directory to illustrate how you can place them in other locations successfully.

Named virtual hosting

You can make your web server host more than one site per IP address by using Apache’s “named virtual hosting” feature. The Name Virtual Host directive in the /etc/httpd/conf/httpd.conf file is used to tell Apache the IP addresses which will participate in this feature.

The containers in the file then tell Apache where it should look for the web pages used on each website. You must specify the IP address for which each container applies.

Named Virtual Hosting Example
NameVirtualHost 97.158.253.26
<VirtualHost *>
Default Directives. (In other words, not site #1 or site #2)
</VirtualHost>
<VirtualHost 97.158.253.26>
servername www.my-site.com
Directives for site #1
</VirtualHost>
<VirtualHost 97.158.253.26>
servername www.my-other-site.com
Directives for site #2
</VirtualHost>

You can also have multiple Name Virtual Host directives, each with a single IP address, in cases where your web server has more than one IP address

Subscribe For More Content