Chapter: Internet & World Wide Web HOW TO PROGRAM - Rich Internet Application Server Technologies - Web Servers (IIS and Apache)

| Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail |

Apache HTTP Server

The Apache HTTP Server, maintained by the Apache Software Foundation, is currently the most popular web server because of its stability, efficiency, portability, security and small size.

Apache HTTP Server

 

The Apache HTTP Server, maintained by the Apache Software Foundation, is currently the most popular web server because of its stability, efficiency, portability, security and small size. It is open source software that runs on UNIX, Linux, Mac OS X, Windows and numerous other platforms.

 

Mac OS X and many versions of Linux come preinstalled with Apache. If your system does not have Apache preinstalled, you can obtain the Apache HTTP Server for a variety of platforms from  httpd.apache.org/download.cgi. For instructions on installing version 2.2 of the Apache HTTP Server on Windows, please visit

 

 http://httpd.apache.org/docs-2.2/platform/windows.html

 

After installing the Apache HTTP Server, start the application. For Windows, open the Start menu, select Programs > Apache HTTP Server [version number] > Control Apache Server > Monitor Apache Servers. Double click on the Apache Service Monitor that appears in your Taskbar, select Apache2, and click Start (Fig. 21.11). For Mac OS X, you can start Apache from the System Preferences by opening the Sharing preference pane and check-ing the checkbox next to Web Sharing. To stop Apache in Windows, open the Apache Ser-vice Monitor, select your server, and click Stop. For Mac OS X, open the Sharing preference pane and uncheck the checkbox next to Web Sharing.

 

All documents that will be requested from an Apache HTTP Server must either be in the default directory (i.e., C:\Program Files\Apache Software Foundation\Apache2.2\ htdocs for Windows, /Library/WebServer/Documents for Mac OS X, and /var/www/html or /var/www for most Linux distros) or in a directory for which an Apache HTTP Server alias is configured. An alias is Apache’s equivalent to Microsoft IIS’s virtual direc-tory. It is a pointer to an existing directory that resides on the local machine or on the net-work. We will create an alias for the examples in this chapter.

Instead of using an administrative utility or set of wizards, we configure the Apache HTTP Server by editing the httpd.conf file. This file contains all the information that


the Apache HTTP Server needs to run correctly and serve web documents. For Windows, the httpd.conf file is located in the conf subdirectory of Apache’s installation directory. For Mac OS X and most Linux distros, it is located in the /etc/apache2/ directory. To edit this file, either open the httpd.conf in a text editor, or in Windows go to the Start menu and select Programs > Apache HTTP Server [version number] > Configure Apache Server > Edit the Apache httpd.conf Configuration File. httpd.conf is a large text file containing all of Apache HTTP Server’s configuration information. In this file, any line that starts with a # is a comment that explains the various configuration options.

An introductory comment at the top of the httpd.conf file explains how the file is organized. After this comment, the configuration information starts with the most impor-tant, global settings. These should have been configured correctly by the Apache installer. Scroll down in the file until you have reached the section titled DocumentRoot (using your text editor’s search function will save time). The DocumentRoot setting specifies Apache’s default directory. In Windows, the default setting is:

 

DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/ htdocs"

 

Now, find the section starting with <IfModule alias_module> and ending with </ IfModule>. To create an alias, we add the following lines below the comment.

 

# This alias is for the examples used in Chapter 21 Alias /Chapter21Test "C:/Chapter21Examples"

 

This creates an alias called Chapter21Test that points to the physical directory C:\Chapter21Examples. We use the name Chapter21Test, but any name that does not conflict with an existing alias is allowed. We created a directory named C:\Chapter21Examples that contains our documents (you should specify an appropriate path on Linux or Mac OS X). Note that in both the name of the alias and the path of the directory to which the alias points we must use forward slashes (/), not backslashes (\).

Once we have created the alias, we must set the access settings of that directory so that users have permission to access it. The default access settings for every directory are to deny access to everybody. In order to override those settings for our new directory, C:\Chapter21Examples, we must create a new Directory entry. We append this new Directory entry to the end of the file:

 

# Begin Chapter21Examples directory access settings <Directory "C:/Chapter21Examples">

 

Options Indexes

 

Order allow,deny

 

Allow from all

 

</Directory>

 

# End Chapter21Examples directory access settings

 

We begin by specifying the location of the directory, then proceed to configure that directory. Indexes on the Options line specifies that if an index file, such as index.html, does not exist, Apache will generate one for you that contains the filenames of every doc-ument in the directory. Order allow,deny specifies that users are permitted access by default, and are denied only if they are specifically blocked. Allow from all specifies that all users are permitted access.

 

Now, the Apache HTTP Server is configured to serve our web document from the C:\Chapter21Examples directory. We need to restart the server so that our changes to httpd.conf file will take effect. Then we will be ready to request documents from the Apache HTTP Server. To restart the server, we must first stop it and start it again. Please refer to the beginning of this section for instructions on how to stop and start the Apache HTTP Server.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.